Change the tree placement to be tail recursive