<garvit244>230_1.py
def kthSmallest( root, k):
    if not root:
        return 0
    
    stack = [root]
    count, curr = 0, root
    
    
    while stack:
        if curr.left:
            stack.append(curr.left)
            curr = curr.left
        else:
            val = stack.pop()
            count += 1
            if count == k:
                return val.val
    
            if val.right:
                stack.append(val.right)
                curr = val.right
    return float('-inf')
def sample_funcname ( var_0 , var_1 ) :
    if not var_0 :
        return 0
    var_3 = [ var_0 ]
    var_4 , var_5 = 0 , var_0
    while var_3 :
        if var_5.left :
            var_3.append ( var_5.left )
            var_5 = var_5.left
        else :
            val = var_3.pop ( )
            var_4 += 1
            if var_4 == var_1 :
                return val.val
            if val.right :
                var_3.append ( val.right )
                var_5 = val.right
    return float ( '-inf' )
