Think I've fixed the tree traversal problem.