<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _save_rest_method(self, method_name, api_name, version, method):
 """Store Rest api methods in a list for lookup at call time. The list is self._rest_methods, a list of tuples: where: <compiled_path> is a compiled regex to match against the incoming URL <path_pattern> is a string representing the original path pattern, checked on insertion to prevent duplicates. -and- <method_dict> is a dict of httpMethod => (method_name, method) This structure is a bit complex, it supports use in two contexts: Creation time: - SaveRestMethod is called repeatedly, each method will have a path, which we want to be compiled for fast lookup at call time - We want to prevent duplicate incoming path patterns, so store the un-compiled path, not counting on a compiled regex being a stable comparison as it is not documented as being stable for this use. - Need to store the method that will be mapped at calltime. - Different methods may have the same path but different http method. Call time: - Quickly scan through the list attempting .match(path) on each compiled regex to find the path that matches. - When a path is matched, look up the API method from the request and get the method name and method config for the matching API method and method name. Args: method_name: A string containing the name of the API method. api_name: A string containing the name of the API. version: A string containing the version of the API. method: A dict containing the method descriptor (as in the api config file). """

    path_pattern = '/'.join((api_name, version, method.get('path', '')))
    http_method = method.get('httpMethod', '').lower()
    for _, path, methods in self._rest_methods:
      if path == path_pattern:
        methods[http_method] = method_name, method
        break
    else:
      self._rest_methods.append(
          (self._compile_path_pattern(path_pattern),
           path_pattern,
           {http_method: (method_name, method)}))