<doocs>0250.Count Univalue Subtrees_1.py
def dfs(root):
    if root is None:
        return True
    left, right = dfs(root.left), dfs(root.right)
    t = True
    if root.left and root.left.val != root.val:
        t = False
    if root.right and root.right.val != root.val:
        t = False
    nonlocal ans
    if left and t and right:
        ans += 1
    return left and t and right
def sample_funcname ( var_1 ) :
    if var_1 is None :
        return True
    left , right = var_0 ( var_1.left ) , var_0 ( var_1.right )
    var_6 = True
    if var_1.left and var_1.left.val != var_1.val :
        var_6 = False
    if var_1.right and var_1.right.val != var_1.val :
        var_6 = False
    nonlocal var_9
    if left and var_6 and right :
        var_9 += 1
    return left and var_6 and right
