make buildTree a bit prettier