fix tree traversal