First level active Item

I am a 3 level menu structure and I need the active parent on the first level. Is there any better way to do a loop searching for the page that is “activeChild” = true or doing this:

{% if page.parent.root %}
{% set bodyClass = page.slug() %}
{# {% set bodyClass = root.children.activeChild().first().slug() %} #}
{% elseif page.parent.parent.root %}
{% set bodyClass = page.parent.slug() %}
{% else %}
{% set bodyClass = page.parent.parent.slug() %}
{% endif %}