Moves to in-house Tree

The TreeNode implementation had some problems, so this switches to a
custom-made solution.
Also checks out correctly on the tree path finding.