comefrom: <doocs>1522.Diameter of N-Ary Tree_1.py
code: def dfs(root):
      if root is None:
          return 0
      nonlocal ans
      m1 = m2 = 0
      for child in root.children:
          t = dfs(child)
          if t > m1:
              m2, m1 = m1, t
          elif t > m2:
              m2 = t
      ans = max(ans, m1 + m2)
      return 1 + m1
masked: def sample_funcname ( var_1 ) :
      if var_1 is None :
          return 0
      nonlocal var_4
      var_6 = var_5 = 0
      for var_8 in var_1.children :
          var_9 = var_0 ( var_8 )
          if var_9 > var_6 :
              var_5 , var_6 = var_6 , var_9
          elif var_9 > var_5 :
              var_5 = var_9
      var_4 = max ( var_4 , var_6 + var_5 )
      return 1 + var_6
  