Traversing node trees

Once you start connecting nodes with one another, you might have pretty complex graphs. We provide three utility functions to traverse the node tree in all possible ways:

traverse_tree_forward(roots, func)

Traverse a tree of nodes in a forward fashion.

traverse_tree_backward(leaves, func)

Traverse a tree of nodes in a backwards fashion.

visit_all_connected(nodes, func[, _seen_nodes])

Visit all nodes that are connected to a list of nodes.

Once you are done traversing, e.g. because you have found the node that you were looking for, you can raise a StopTraverse exception to stop the traversal.

StopTraverse

Exception that should be raised by callback functions to stop the traversal of a tree.