completing tree build on click function