construct tree from traversal