<doocs>0501.Find Mode in Binary Search Tree_1.py
def dfs(root):
    if root is None:
        return
    nonlocal mx, prev, ans, cnt
    dfs(root.left)
    cnt = cnt + 1 if prev == root.val else 1
    if cnt > mx:
        ans = [root.val]
        mx = cnt
    elif cnt == mx:
        ans.append(root.val)
    prev = root.val
    dfs(root.right)
def sample_funcname ( var_1 ) :
    if var_1 is None :
        return
    nonlocal var_3 , var_4 , var_5 , var_6
    var_0 ( var_1.left )
    var_6 = var_6 + 1 if var_4 == var_1.val else 1
    if var_6 > var_3 :
        var_5 = [ var_1.val ]
        var_3 = var_6
    elif var_6 == var_3 :
        var_5.append ( var_1.val )
    var_4 = var_1.val
    var_0 ( var_1.right )
