I'm trying to build a menu from a SharePoint list but I need to group the main menus and then add links to the appropiate main menus. I have separated the links using the LinkType column if it is a header or a header with a link.

What I need help with is to get the distinct of the Group columns or how to group the groups columns.