def is_equal_or_parent_of(page1, page2):
    """
    Determines whether a given page is equal to or the parent of another page.
    This is especially handy when generating the navigation. The following
    example adds a CSS class ``current`` to the current main navigation entry::

        {% for page in navigation %}
            <a
            {% if page|is_equal_or_parent_of:feincms_page %}
                class="current"
            {% endif %}
            >{{ page.title }}</a>
        {% endfor %}
    """
    try:
        return page1.is_ancestor_of(page2, include_self=True)
    except (AttributeError, ValueError):
        return False

    Determines whether a given page is equal to or the parent of another page.
    This is especially handy when generating the navigation. The following
    example adds a CSS class ``current`` to the current main navigation entry::

        {% for page in navigation %}
            <a
            {% if page|is_equal_or_parent_of:feincms_page %}
                class="current"
            {% endif %}
            >{{ page.title }}</a>
        {% endfor %}
    
feincms/templatetags/feincms_page_tags.py