from core.settings_navigation import build_settings_navigation


def settings_hierarchy_nav(request):
    match = getattr(request, "resolver_match", None)
    if match is None:
        return {}

    url_name = str(getattr(match, "url_name", "") or "")
    settings_nav = build_settings_navigation(url_name)

    if not settings_nav:
        return {}
    return {"settings_nav": settings_nav}
