fixed error with tree traversal.