code: def RemoveScanNode(self, path_spec):
      
      scan_node = self._scan_nodes.get(path_spec, None)
      if not scan_node:
        return None
  
      if scan_node.sub_nodes:
        raise RuntimeError('Scan node has sub nodes.')
  
      parent_scan_node = scan_node.parent_node
      if parent_scan_node:
        parent_scan_node.sub_nodes.remove(scan_node)
  
      if path_spec == self._root_path_spec:
        self._root_path_spec = None
      del self._scan_nodes[path_spec]
  
      if path_spec.IsFileSystem():
        del self._file_system_scan_nodes[path_spec]
  
      return parent_scan_node
docs: Removes a scan node of a certain path specification.
  
      Args:
        path_spec (PathSpec): path specification.
  
      Returns:
        SourceScanNode: parent scan node or None if not available.
  
      Raises:
        RuntimeError: if the scan node has sub nodes.