added function for making a tree from an array