Flatten calls the walk function on each node in the Graph in topological
order, starting with the leaves and traversing up to the roots. The same
Graph will always be traversed in the same order.
Every vertex in the Graph is visited once; any cycles in the graph are
skipped.