initial pseudocode for better tree building
integrating the new tree building code