Traversal rewritten to non-recursive version.