<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def AddPathSegment(self, path_segment, scan_object):
 """Adds a path segment. Args: path_segment: a string containing the path segment. scan_object: a scan object, either a scan tree sub node (instance of PathFilterScanTreeNode) or a string containing a path. Raises: ValueError: if the node already contains a scan object for the path segment. """

    if path_segment in self._path_segments:
      raise ValueError('Path segment already set.')

    if isinstance(scan_object, PathFilterScanTreeNode):
      scan_object.parent = self

    self._path_segments[path_segment] = scan_object