code: def _CheckLocation(self, file_entry, search_depth):
      
      if self._location_segments is None:
        return False
  
      if search_depth < 0 or search_depth > self._number_of_location_segments:
        return False
  
      # Note that the root has no entry in the location segments and
      # no name to match.
      if search_depth == 0:
        segment_name = ''
      else:
        segment_name = self._location_segments[search_depth - 1]
  
        if self._is_regex:
          if isinstance(segment_name, py2to3.STRING_TYPES):
            # Allow '\n' to be matched by '.' and make '\w', '\W', '\b', '\B',
            # '\d', '\D', '\s' and '\S' Unicode safe.
            flags = re.DOTALL | re.UNICODE
            if not self._is_case_sensitive:
              flags |= re.IGNORECASE
  
            try:
              segment_name = r'^{0:s}$'.format(segment_name)
              segment_name = re.compile(segment_name, flags=flags)
            except sre_constants.error:
              # TODO: set self._location_segments[search_depth - 1] to None ?
              return False
  
            self._location_segments[search_depth - 1] = segment_name
  
        elif not self._is_case_sensitive:
          segment_name = segment_name.lower()
          self._location_segments[search_depth - 1] = segment_name
  
      if search_depth > 0:
        if self._is_regex:
          if not segment_name.match(file_entry.name):  # pylint: disable=no-member
            return False
  
        elif self._is_case_sensitive:
          if segment_name != file_entry.name:
            return False
  
        elif segment_name != file_entry.name.lower():
          return False
  
      return True
docs: Checks the location find specification.
  
      Args:
        file_entry (FileEntry): file entry.
        search_depth (int): number of location path segments to compare.
  
      Returns:
        bool: True if the file entry matches the find specification, False if not.