Put the dequeued tree node to TreeMap having key as horizontal distance . Every time we find a node having same horizontal distance we need to replace the data in the map .
m [ hd ] = temp . data NEW_LINE