Fix process_tree function so that it calls pre/post for each child.