modified sub tree creation, added function to traverse constructed tree