<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def path_split(self, path):
 """ Splits a path into the part matching this middleware and the part remaining. If path does not exist, it returns a pair of None values. If the regex matches the entire pair, the second item in returned tuple is None. Args: path (str):
 The url to split Returns: Tuple matching_path (str or None):
 The beginning of the path which matches this middleware or None if it does not match remaining_path (str or None):
 The 'rest' of the path, following the matching part """


        match = self.path.match(path)
        if match is None:
            return None, None

        # split string at position
        the_rest = path[match.end():]

        # ensure we split at a '/' character
        if the_rest:
            if match.group().endswith('/'):
                pass
            elif the_rest.startswith('/'):
                pass
            else:
                return None, None

        if self.IGNORE_TRAILING_SLASH and the_rest == '/':
            the_rest = ''

        return match, the_rest