class_docstr:   Fundamental data type used to build file system tree structures.
  
    If CHILDREN is None, then the node represents a file. Otherwise, CHILDREN
  is a list of the nodes representing that directory's children.
  
    NAME is simply the name of the file or directory. CONTENTS is a string
  holding the file's contents (if a file).
class_docstr_tok: ["Fundamental","data","type","used","to","build","file","system","tree","structures",".","If","CHILDREN","is","None",",","then","the","node","represents","a","file",".","Otherwise",",","CHILDREN","is","a","list","of","the","nodes","representing","that","directory","'s","children",".","NAME","is","simply","the","name","of","the","file","or","directory",".","CONTENTS","is","a","string","holding","the","file","'s","contents","(","if","a","file",")","."]
code: def add_child(self, newchild):
      assert not self.is_file()
      for a in self.children:
          if a.name == newchild.name:
              if newchild.is_file():
                  a.contents = newchild.contents
                  a.path = os.path.join(self.path, newchild.name)
              else:
                  for i in newchild.children:
                      a.add_child(i)
              break
      else:
          self.children.append(newchild)
          newchild.path = os.path.join(self.path, newchild.name)
  
imports: import os
  import os.path
  import stat
  import sys
label_desc: Use image node_id 2 for calling the TreeNode obj's underlying member method code with example usage: obj.add_child(newchild) without return types