Solved binary tree problem