build tree, recursion