Constructing the positions of all tree nodes