Added tree traversal method