updated parse tree traversal method.