construct tree