Switch buildTree to a fully recursive version.