{% if item.hasChildren() and (options.depth is not same as 0) and item.getDisplayChildren() %}
{# Top menu level start #}
{% if item.isRoot() %}
{% else %}
{# get attributes from item + the ones passed from parent #}
{% set ulAttributes = item.getChildrenAttributes() %}
{% set ulAttributes = ulAttributes|merge(itemAttributes is defined ? itemAttributes : {}) %}
{% endif %}
{# Submenu levels start #}
{% for child in item.getChildren() %}
{% if child.isDisplayed() %}
{% set showChildren = (child.hasChildren() and child.getDisplayChildren() ? true : false) %}
{% set liAttributes = child.getAttributes() %}
{% set isAncestor = matcher.isAncestor(child, options['matchingDepth']) %}
{# save default classes for the item #}
{% set liClasses = (liAttributes.class is defined) ? liAttributes.class ~ ' nav-group' : 'nav-group' %}
{# fetch classes from options and merge with the default classes #}
{% set liAttributes = liAttributes|merge(buildMenuClasses(child, matcher, options, liClasses)) %}
{# Menu item start #}