To store the node and the label and perform traversal
Queue < pair > qt = new LinkedList < > ( ) ; qt . add ( new pair ( root , 0 ) ) ; int count = 1 , b = 0 , a = 0 ; while ( ! qt . isEmpty ( ) ) { pair temp = qt . peek ( ) ; qt . poll ( ) ;