Clean the code of the tree generator