def _ScanNode(self, scan_context, scan_node, auto_recurse=True):
    if not scan_context:
      raise ValueError(u'Invalid scan context.')

    if not scan_node:
      raise ValueError(u'Invalid scan node.')

    scan_path_spec = scan_node.path_spec

    if not scan_node.IsSystemLevel():
      system_level_file_entry = None

    else:
      system_level_file_entry = resolver.Resolver.OpenFileEntry(
          scan_node.path_spec, resolver_context=self._resolver_context)

      if system_level_file_entry is None:
        raise errors.BackEndError(u'Unable to open file entry.')

      if system_level_file_entry.IsDirectory():
        scan_context.SetSourceType(definitions.SOURCE_TYPE_DIRECTORY)
        return

      source_path_spec = self.ScanForStorageMediaImage(scan_node.path_spec)
      if source_path_spec:
        scan_node.scanned = True
        scan_node = scan_context.AddScanNode(source_path_spec, scan_node)

        if system_level_file_entry.IsDevice():
          scan_context.SetSourceType(
              definitions.SOURCE_TYPE_STORAGE_MEDIA_DEVICE)
        else:
          scan_context.SetSourceType(
              definitions.SOURCE_TYPE_STORAGE_MEDIA_IMAGE)

        if not auto_recurse:
          return

      # In case we did not find a storage media image type we keep looking
      # since not all RAW storage media image naming schemas are known and
      # its type can only detected by its content.

    source_path_spec = None
    while True:
      # No need to scan a file systems scan node for volume systems.
      if scan_node.type_indicator in definitions.FILE_SYSTEM_TYPE_INDICATORS:
        break

      # No need to scan a locked scan node e.g. an encrypted volume.
      if scan_context.IsLockedScanNode(scan_node.path_spec):
        break

      source_path_spec = self.ScanForVolumeSystem(scan_node.path_spec)
      # Nothing found in the volume system scan.
      if not source_path_spec:
        break

      if not scan_context.HasScanNode(source_path_spec):
        scan_node.scanned = True
        scan_node = scan_context.AddScanNode(source_path_spec, scan_node)

        if system_level_file_entry and system_level_file_entry.IsDevice():
          scan_context.SetSourceType(
              definitions.SOURCE_TYPE_STORAGE_MEDIA_DEVICE)
        else:
          scan_context.SetSourceType(
              definitions.SOURCE_TYPE_STORAGE_MEDIA_IMAGE)

      if scan_node.type_indicator in definitions.VOLUME_SYSTEM_TYPE_INDICATORS:
        # For VSS add a scan node for the current volume.
        if scan_node.type_indicator == definitions.TYPE_INDICATOR_VSHADOW:
          path_spec = self.ScanForFileSystem(scan_node.path_spec.parent)
          if path_spec:
            scan_context.AddScanNode(path_spec, scan_node.parent_node)

        # Determine the path specifications of the sub file entries.
        file_entry = resolver.Resolver.OpenFileEntry(
            scan_node.path_spec, resolver_context=self._resolver_context)

        for sub_file_entry in file_entry.sub_file_entries:
          sub_scan_node = scan_context.AddScanNode(
              sub_file_entry.path_spec, scan_node)

          # Since scanning for file systems in VSS snapshot volumes can
          # be expensive we only do this when explicitly asked for.
          if scan_node.type_indicator != definitions.TYPE_INDICATOR_VSHADOW:
            if auto_recurse or not scan_context.updated:
              self._ScanNode(
                  scan_context, sub_scan_node, auto_recurse=auto_recurse)

        # We already have already scanned for the file systems in _ScanNode().
        return

      elif scan_node.type_indicator in (
          definitions.ENCRYPTED_VOLUME_TYPE_INDICATORS):
        file_object = resolver.Resolver.OpenFileObject(
            scan_node.path_spec, resolver_context=self._resolver_context)
        is_locked = not file_object or file_object.is_locked
        file_object.close()

        if is_locked:
          scan_context.LockScanNode(scan_node.path_spec)

          # For BitLocker To Go add a scan node for the unencrypted part
          # of the volume.
          if scan_node.type_indicator == definitions.TYPE_INDICATOR_BDE:
            path_spec = self.ScanForFileSystem(scan_node.path_spec.parent)
            if path_spec:
              scan_context.AddScanNode(path_spec, scan_node.parent_node)

      if not auto_recurse and scan_context.updated:
        return

      # Nothing new found.
      if not scan_context.updated:
        break

    # In case we did not find a volume system type we keep looking
    # since we could be dealing with a storage media image that contains
    # a single volume.

    # No need to scan the root of a volume system for a file system.
    if (scan_node.path_spec.type_indicator in (
        definitions.VOLUME_SYSTEM_TYPE_INDICATORS) and
        getattr(scan_node.path_spec, u'location', None) == u'/'):
      pass

    # No need to scan a locked scan node e.g. an encrypted volume.
    elif scan_context.IsLockedScanNode(scan_node.path_spec):
      pass

    # Since scanning for file systems in VSS snapshot volumes can
    # be expensive we only do this when explicitly asked for.
    elif (scan_node.type_indicator == definitions.TYPE_INDICATOR_VSHADOW and
          auto_recurse and scan_node.path_spec != scan_path_spec):
      pass

    elif scan_node.type_indicator not in (
        definitions.FILE_SYSTEM_TYPE_INDICATORS):
      source_path_spec = self.ScanForFileSystem(scan_node.path_spec)
      if not source_path_spec:
        # Since RAW storage media image can only be determined by naming schema
        # we could have single file that is not a RAW storage media image yet
        # matches the naming schema.
        if scan_node.path_spec.type_indicator == definitions.TYPE_INDICATOR_RAW:
          scan_node = scan_context.RemoveScanNode(scan_node.path_spec)

          # Make sure to override the previously assigned source type.
          scan_context.source_type = definitions.SOURCE_TYPE_FILE
        else:
          scan_context.SetSourceType(definitions.SOURCE_TYPE_FILE)

      elif not scan_context.HasScanNode(source_path_spec):
        scan_node.scanned = True
        scan_node = scan_context.AddScanNode(source_path_spec, scan_node)

        if system_level_file_entry and system_level_file_entry.IsDevice():
          scan_context.SetSourceType(
              definitions.SOURCE_TYPE_STORAGE_MEDIA_DEVICE)
        else:
          scan_context.SetSourceType(
              definitions.SOURCE_TYPE_STORAGE_MEDIA_IMAGE)

    # If all scans failed mark the scan node as scanned so we do not scan it
    # again.
    if not scan_node.scanned:
      scan_node.scanned = True

    return
Checks the date_range_query generation function. Since it's pretty simple, running all the tests as one
dataset/ETHPy150Open log2timeline/dfvfs/dfvfs/helpers/source_scanner.py/SourceScanner._ScanNode--crossover with--dataset/ETHPy150Open moonlitesolutions/SolrClient/test/test_reindexer.py/ReindexerTests.test_solr_to_solr_resume_basic