build a tree