<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def match(self, method, path):
 """find handler from registered rules Example: handler, params = match('GET', '/path') """

        segments = path.split('/')
        while len(segments):
            index = '/'.join(segments)
            if index in self.__idx__:
                handler, params = self.match_rule(method, path,
                                                  self.__idx__[index])
                if handler:
                    return handler, params
            segments.pop()
        return None, None