We go to right only when left does not contain given data . This way we make sure that correct path node is stored in temp [ ]
right = None NEW_LINE left , temp , nextpos = reverseTreePathUtil ( root . left , data , temp , level + 1 , nextpos ) ; NEW_LINE if ( left == None ) : NEW_LINE INDENT right , temp , nextpos = reverseTreePathUtil ( root . right , data , temp , level + 1 , nextpos ) ; NEW_LINE DEDENT