def _GetCachedFileByPath(self, key_path_upper):
longest_key_path_prefix_upper = '<STR_LIT>'<EOL>longest_key_path_prefix_length = len(longest_key_path_prefix_upper)<EOL>for key_path_prefix_upper in self._registry_files:<EOL><INDENT>if key_path_upper.startswith(key_path_prefix_upper):<EOL><INDENT>key_path_prefix_length = len(key_path_prefix_upper)<EOL>if key_path_prefix_length > longest_key_path_prefix_length:<EOL><INDENT>longest_key_path_prefix_upper = key_path_prefix_upper<EOL>longest_key_path_prefix_length = key_path_prefix_length<EOL><DEDENT><DEDENT><DEDENT>if not longest_key_path_prefix_upper:<EOL><INDENT>return None, None<EOL><DEDENT>registry_file = self._registry_files.get(<EOL>longest_key_path_prefix_upper, None)<EOL>return longest_key_path_prefix_upper, registry_file<EOL>
Retrieves a cached Windows Registry file for a key path.

        Args:
          key_path_upper (str): Windows Registry key path, in upper case with
              a resolved root key alias.

        Returns:
          tuple: consist:

            str: key path prefix
            WinRegistryFile: corresponding Windows Registry file or None if not
                available.