Added TREE solution (quick & dirty, not actually building the tree)