added tree traversal code