Where to edit this loop

Hello Dears

Actually i`m planning to use this file

erpnext/setup/doctype/item_group/templates/item_group_row.html

to make a dynamic website menu and include this file into header or navbar

but i wanna to know where to edit the loop which get the item groups info inside this file

file content

<div>
        <a href={{ route }}>{{ item_group_name }}</a>
</div>

only
so i wanna to edit the loop so i can make the menu multilevel coz i have more than 4 levels with around 64 item group

please help

any updates please ?