function to insert elements of the tree to map m
static void insertToHash ( Node root , HashSet < Integer > s ) { if ( root == null ) return ; insertToHash ( root . left , s ) ; s . add ( root . data ) ; insertToHash ( root . right , s ) ; }