MIRROR OF ABOVE CODE FOR RIGHT SUBTREE Note that we reach here only when node was not found in left subtree
dr = printkDistanceNode ( root . right , target , k ) NEW_LINE if dr != - 1 : NEW_LINE INDENT if ( dr + 1 == k ) : NEW_LINE INDENT print root . data NEW_LINE DEDENT else : NEW_LINE INDENT printkDistanceNodeDown ( root . left , k - dr - 2 ) NEW_LINE DEDENT return 1 + dr NEW_LINE DEDENT