tree builder for 1D