Added a tree generating function