@register.filter
def active_trail(menu, url):
    return menu.filter(path=get_clean_url(url)).get_ancestors(include_self=True) if menu else []
Get the active menu item based on url provided, and all of its ancestors
dataset/ETHPy150Open Wtower/django-ninecms/ninecms/templatetags/ninecms_extras.py/active_trail