Implemented state() for tree in tree traversal exercises