def METHOD_NAME(urlpatterns, suffix_pattern, suffix_required):
    ret = []
    for urlpattern in urlpatterns:
        if isinstance(urlpattern, URLResolver):
            # Set of included URL patterns
            regex = urlpattern.pattern.regex.pattern
            namespace = urlpattern.namespace
            app_name = urlpattern.app_name
            kwargs = urlpattern.default_kwargs
            # Add in the included patterns, after applying the suffixes
            patterns = METHOD_NAME(urlpattern.url_patterns,
                                             suffix_pattern,
                                             suffix_required)
            ret.append(re_path(regex, include(patterns, namespace, app_name), kwargs))
        else:
            # Regular URL pattern
            regex = urlpattern.pattern.regex.pattern.rstrip("$") + suffix_pattern
            view = urlpattern.callback
            kwargs = urlpattern.default_args
            name = urlpattern.name
            # Add in both the existing and the new urlpattern
            if not suffix_required:
                ret.append(urlpattern)
            ret.append(re_path(regex, view, kwargs, name))
    return ret