Maintain index to count number of nodes processed so far
count = 0 NEW_LINE res = kthSmallest ( root ) NEW_LINE if ( res == None ) : NEW_LINE INDENT print ( " There ▁ are ▁ less ▁ than ▁ k ▁ nodes ▁ in ▁ the ▁ BST " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " K - th ▁ Smallest ▁ Element ▁ is ▁ " , res . data ) NEW_LINE DEDENT