A queue of pairs to do bfs traversal and keep track if the node is a left or right child if boolean value is true then it is a left child .
Queue < pair > q = new LinkedList < > ( ) ; q . add ( new pair ( root , false ) ) ; int sum = 0 ;