Python with generators
def iterate_tree(root):\n        # inorder tree traversal generator\n        if root.left:\n            for i in iterate_tree(root.left):\n                yield
    def iterate_tree(root):\n        # inorder tree traversal generator\n        if root.left:\n            for i in iterate_tree(root.left):\n                yield i\n        yield root\n        if root.right:\n            for i in iterate_tree(root.right):\n                yield i\n    \n    class Solution(object):\n        def kthSmallest(self, root, k):\n            # iterate over tree\n            for p, v in enumerate(iterate_tree(root)):\n                if p+1 == k:\n                    return v.val
['Python']