making NodeIterator traversal static so it can be shared with TreeWalker