implemented foldTree for creating a balanced, binary tree.