

def kthSmallest(self, root, k):
    (s, cur, rank) = ([], root, 0)
    while (s or cur):
        if cur:
            s.append(cur)
            cur = cur.left
        else:
            cur = s.pop()
            rank += 1
            if (rank == k):
                return cur.val
            cur = cur.right
    return float('-inf')

dataset/ETHPy150Open kamyu104/LeetCode/Python/kth-smallest-element-in-a-bst.py Solution.kthSmallest/original