Liquid
<h4>Best way, using links.size check on menu</h4>
{% for link in menus.some-menu.links %}
{% assign child_link_handle = link.title | handle %}
{% if menus[child_link_handle].links.size > 0 %}
{{ link.title }}<br>
...expecting menu with links in it...<br>
{% for childlink in menus[child_link_handle].links %}
— {{ childlink.title | link_to: childlink.url }}<br>
{% endfor %}
{% endif %}
{% endfor %}
<h4>Good enough way, using == blank check on menu links</h4>
{% for link in menus.some-menu.links %}
{% assign child_link_handle = link.title | handle %}
{% if menus[child_link_handle].links != blank %}
{{ link.title }}<br>
...expecting menu with links in it...<br>
{% for childlink in menus[child_link_handle].links %}
— {{ childlink.title | link_to: childlink.url }}<br>
{% endfor %}
{% endif %}
{% endfor %}
<h4>Bad way, not using == blank on links, nor links.size</h4>
{% for link in menus.some-menu.links %}
{% assign child_link_handle = link.title | handle %}
{% if menus[child_link_handle] != blank %}
{{ link.title }}<br>
...expecting menu with links in it...<br>
{% for childlink in menus[child_link_handle].links %}
— {{ childlink.title | link_to: childlink.url }}<br>
{% endfor %}
{% endif %}
{% endfor %}
Output
Best way, using links.size check on menu
Submenu 1...expecting menu with links in it...
— Link 1
— Link 2
— Link 3
Good enough way, using == blank check on menu links
Submenu 1...expecting menu with links in it...
— Link 1
— Link 2
— Link 3
Bad way, not using == blank on links, nor links.size
Submenu 1...expecting menu with links in it...
— Link 1
— Link 2
— Link 3
Submenu 2
...expecting menu with links in it...