Follow up:

What if the BST is modified (insert/delete operations) often and you need to find the kth smallest frequently? How would you optimize the kthSmallest routine?

I think this is about find next smallest element in BST, with time complexity being O(log(n))

which should be better than O(k)

Right?