<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def GetAPFSFileEntryByPathSpec(self, path_spec):
 """Retrieves the APFS file entry for a path specification. Args: path_spec (PathSpec):
 a path specification. Returns: pyfsapfs.file_entry: file entry. Raises: PathSpecError: if the path specification is missing location and identifier. """

    # Opening a file by identifier is faster than opening a file by location.
    location = getattr(path_spec, 'location', None)
    identifier = getattr(path_spec, 'identifier', None)

    if identifier is not None:
      fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_identifier(
          identifier)
    elif location is not None:
      fsapfs_file_entry = self._fsapfs_volume.get_file_entry_by_path(location)
    else:
      raise errors.PathSpecError(
          'Path specification missing location and identifier.')

    return fsapfs_file_entry