Compare height for already present node at similar horizontal distance
else { pair < int , int > p = m [ hd ] ; if ( p . second <= curr ) { m [ hd ] . second = curr ; m [ hd ] . first = root -> data ; } }