reduced the number of functions used to visit the tree