<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _ExtractDataStream( self, file_entry, data_stream_name, destination_path, output_writer, skip_duplicates=True):
 """Extracts a data stream. Args: file_entry (dfvfs.FileEntry):
 file entry containing the data stream. data_stream_name (str):
 name of the data stream. destination_path (str):
 path where the extracted files should be stored. output_writer (CLIOutputWriter):
 output writer. skip_duplicates (Optional[bool]):
 True if files with duplicate content should be skipped. """

    if not data_stream_name and not file_entry.IsFile():
      return

    display_name = path_helper.PathHelper.GetDisplayNameForPathSpec(
        file_entry.path_spec)

    if skip_duplicates:
      try:
        digest = self._CalculateDigestHash(file_entry, data_stream_name)
      except (IOError, dfvfs_errors.BackEndError) as exception:
        output_writer.Write((
            '[skipping] unable to read content of file entry: {0:s} '
            'with error: {1!s}\n').format(display_name, exception))
        return

      if not digest:
        output_writer.Write(
            '[skipping] unable to read content of file entry: {0:s}\n'.format(
                display_name))
        return

      duplicate_display_name = self._digests.get(digest, None)
      if duplicate_display_name:
        output_writer.Write((
            '[skipping] file entry: {0:s} is a duplicate of: {1:s} with '
            'digest: {2:s}\n').format(
                display_name, duplicate_display_name, digest))
        return

      self._digests[digest] = display_name

    target_directory, target_filename = self._CreateSanitizedDestination(
        file_entry, file_entry.path_spec, data_stream_name, destination_path)

    if not os.path.isdir(target_directory):
      os.makedirs(target_directory)

    target_path = os.path.join(target_directory, target_filename)

    if os.path.exists(target_path):
      output_writer.Write((
          '[skipping] unable to export contents of file entry: {0:s} '
          'because exported file: {1:s} already exists.\n').format(
              display_name, target_path))
      return

    try:
      self._WriteFileEntry(file_entry, data_stream_name, target_path)
    except (IOError, dfvfs_errors.BackEndError) as exception:
      output_writer.Write((
          '[skipping] unable to export contents of file entry: {0:s} '
          'with error: {1!s}\n').format(display_name, exception))

      try:
        os.remove(target_path)
      except (IOError, OSError):
        pass