Base case
if ( not root ) : NEW_LINE INDENT return None NEW_LINE DEDENT if ( root . data == node or ( kthAncestorDFS ( root . left , node , k ) ) or ( kthAncestorDFS ( root . right , node , k ) ) ) : NEW_LINE INDENT if ( k [ 0 ] > 0 ) : NEW_LINE INDENT k [ 0 ] -= 1 NEW_LINE DEDENT elif ( k [ 0 ] == 0 ) : NEW_LINE DEDENT