def METHOD_NAME(urlconf, patterns=None, namespace=None):
    """
    Iterate through all patterns in the given Django URLconf.  Yields
    `(viewname, route)` tuples, where `viewname` is the fully-qualified view name
    (including its namespace, if any), and `route` is a regular expression that
    corresponds to the part of the pattern that contains any capturing groups.
    """
    if patterns is None:
        patterns = urlconf.urlpatterns
    for pattern in patterns:
        # Resolve if it's a route or an include
        if isinstance(pattern, URLPattern):
            viewname = pattern.name
            if viewname is None and namespace not in NAMESPACES_WITH_UNNAMED_VIEWS:
                raise AssertionError(
                    f"namespace {namespace} cannot contain unnamed views"
                )
            if namespace and viewname is not None:
                viewname = f"{namespace}:{viewname}"
            yield (viewname, pattern.pattern)
        elif isinstance(pattern, URLResolver):
            if len(pattern.default_kwargs.keys()) > 0:
                raise AssertionError("resolvers are not expected to have kwargs")
            if pattern.namespace and namespace is not None:
                raise AssertionError("nested namespaces are not currently supported")
            if pattern.namespace in IGNORE_NAMESPACES:
                continue
            yield from METHOD_NAME(
                urlconf, pattern.url_patterns, namespace or pattern.namespace
            )
        else:
            raise AssertionError("unknown pattern class")