code: def _add_to_package_contents(self, pkgroot, node_path, hashes, target,
                                   source_path, transform, user_meta_hash):
          
          assert isinstance(node_path, list)
          assert user_meta_hash is None or isinstance(user_meta_hash, str)
  
          contents = pkgroot
  
          if not node_path:
              # Allow setting metadata on the root node, but that's it.
              assert target is TargetType.GROUP
              contents.metadata_hash = user_meta_hash
              return
  
          ptr = contents
          for node in node_path[:-1]:
              ptr = ptr.children[node]
  
          if target is TargetType.GROUP:
              node = GroupNode(
                  children=dict(),
                  metadata_hash=user_meta_hash
              )
          else:
              node = FileNode( # pylint:disable=R0204
                  hashes=hashes,
                  metadata=dict(
                      q_ext=transform,
                      q_path=source_path,
                      q_target=target.value
                  ),
                  metadata_hash=user_meta_hash
              )
  
          ptr.children[node_path[-1]] = node
docs: Adds an object (name-hash mapping) or group to package contents.