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_2
      var_4 = var_3 = 0
      for var_5 in var_1.children :
          var_6 = var_0 ( var_5 )
          if var_6 > var_4 :
              var_3 , var_4 = var_4 , var_6
          elif var_6 > var_3 :
              var_3 = var_6
      var_2 = max ( var_2 , var_4 + var_3 )
      return 1 + var_4
  