Python Solution using iteration
 class Solution:\n            # @param {TreeNode} root\n            # @param {integer} k\n            # @return {integer}\n            def kthSmallest(self, roo
     class Solution:\n            # @param {TreeNode} root\n            # @param {integer} k\n            # @return {integer}\n            def kthSmallest(self, root, k):\n                i=0\n                stack=[]\n                node=root\n                while node or stack:\n                    while node:\n                        stack.append(node)\n                        node=node.left\n                    node=stack.pop()\n                    i+=1\n                    if i==k:\n                        return node.val\n                    node=node.right\n\nFor the follow up question, I think we could add a variable to the TreeNode to record the size of the left subtree. When insert or delete a node in the left subtree, we increase or decrease it by 1. So we could know whether the kth smallest element is in the left subtree or in the right subtree by compare the size with k.
['Python']