{% apply spaceless %}

<ul>
    {% for item in cpNavItems %}
        {% set children = item.getChildrenForCurrentUser() %}

        {% set selected = item.isSelected() %}
        {% set activeOrActiveChild = item.isSelected() %}

        {% if children %}
            {% for item in children %}
                {% set itemIsSelected = (item.isSelected() or (selectedSubnavItem is defined and selectedSubnavItem == item.handle) and selected) %}

                {% if itemIsSelected %}
                    {% set 