def _CheckKeyPath(self, registry_key, search_depth):
if self._key_path_segments is None:<EOL><INDENT>return False<EOL><DEDENT>if search_depth < <NUM_LIT:0> or search_depth > self._number_of_key_path_segments:<EOL><INDENT>return False<EOL><DEDENT>if search_depth == <NUM_LIT:0>:<EOL><INDENT>segment_name = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>segment_name = self._key_path_segments[search_depth - <NUM_LIT:1>]<EOL>if self._is_regex:<EOL><INDENT>if isinstance(segment_name, py2to3.STRING_TYPES):<EOL><INDENT>flags = re.DOTALL | re.IGNORECASE | re.UNICODE<EOL>try:<EOL><INDENT>segment_name = r'<STR_LIT>'.format(segment_name)<EOL>segment_name = re.compile(segment_name, flags=flags)<EOL><DEDENT>except sre_constants.error:<EOL><INDENT>return False<EOL><DEDENT>self._key_path_segments[search_depth - <NUM_LIT:1>] = segment_name<EOL><DEDENT><DEDENT>else:<EOL><INDENT>segment_name = segment_name.lower()<EOL>self._key_path_segments[search_depth - <NUM_LIT:1>] = segment_name<EOL><DEDENT><DEDENT>if search_depth > <NUM_LIT:0>:<EOL><INDENT>if self._is_regex:<EOL><INDENT>if not segment_name.match(registry_key.name):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>elif segment_name != registry_key.name.lower():<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL>
Checks the key path find specification.

        Args:
          registry_key (WinRegistryKey): Windows Registry key.
          search_depth (int): number of key path segments to compare.

        Returns:
          bool: True if the Windows Registry key matches the find specification,
              False if not.