recursion iterative reconstruct tree