Improved the performance of tree generation by inserting new nodes into sorted position as opposed to push and resort.