Hello!
I understand the standard horizontal menu template BITRIX. It contains the following code checking the nesting level of the current and previous menu items:
<?if ($previousLevel && $arItem["DEPTH_LEVEL"] < $previousLevel):?> <?= str_repeat("</ul></li>", ($previousLevel - $arItem["DEPTH_LEVEL"])); ?> <? endif ?> If validation is performed, then open list tags are closed. But I just can not understand why to compare 2 times? That is, the current level is compared with the previous one, we get either true, or false and then compare again, using &&. Everything works fine if you write simply:
<?if ($arItem["DEPTH_LEVEL"] < $previousLevel):?>