Most viewed recipes by Henry James http://code.activestate.com/recipes/users/2696289/views/2005-12-14T16:57:54-08:00ActiveState Code RecipesNon-recursive (and non-tracking) traversal of a (DOM) tree (Python)
2005-12-14T16:57:54-08:00Henry Jameshttp://code.activestate.com/recipes/users/2696289/http://code.activestate.com/recipes/461776-non-recursive-and-non-tracking-traversal-of-a-dom-/
<p style="color: grey">
Python
recipe 461776
by <a href="/recipes/users/2696289/">Henry James</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
Revision 3.
</p>
<p>A methode to traverse a tree (or the rest of a tree starting from a node with unkown position) depth-first without recursion and without mandatorily keeping track of the position of the current node; requires each node to have reference acess to its parent, first child and next sibling, therefore especially suitable for DOM trees.</p>