build the local tree.

now need to merge the nodes to make sure there is no overlap.