correcting tree traversal