Boilerplate code to build a tree