scan was recently made available in TensorFlow.

scan lets us write loops inside a computation graph, allowing backpropagation and all. We could explicitly unroll the loops ourselves, creating new graph nodes for each loop iteration, but then the number of iterations is fixed instead of dynamic, and graph creation can be extremely slow.