code: def AddScanNode(self, path_spec, parent_scan_node):
      
      scan_node = self._scan_nodes.get(path_spec, None)
      if scan_node:
        raise KeyError('Scan node already exists.')
  
      scan_node = SourceScanNode(path_spec)
      if parent_scan_node:
        if parent_scan_node.path_spec not in self._scan_nodes:
          raise RuntimeError('Parent scan node not present.')
        scan_node.parent_node = parent_scan_node
        parent_scan_node.sub_nodes.append(scan_node)
  
      if not self._root_path_spec:
        self._root_path_spec = path_spec
  
      self._scan_nodes[path_spec] = scan_node
  
      if path_spec.IsFileSystem():
        self._file_system_scan_nodes[path_spec] = scan_node
  
      self.updated = True
      return scan_node
docs: Adds a scan node for a certain path specification.
  
      Args:
        path_spec (PathSpec): path specification.
        parent_scan_node (SourceScanNode): parent scan node or None.
  
      Returns:
        SourceScanNode: scan node.
  
      Raises:
        KeyError: if the scan node already exists.
        RuntimeError: if the parent scan node is not present.