Display an entry's level 1 categories only if the entry is not related to any of that category's children
Collecting all of the categories' ancestors is probably the way to go in that case. So the solution you already posted within your question is more or less the same as I was about to post.

Instead of having a conditional in the output loop, you could also prepare an array of your bottom level category models using Craft's without filter (I always try to separate output from query / logic blocks in my templates).

This works with any number of category levels.

{% set allCategories = craft.categories.relatedTo(entry) %}

{% set ancestorCatIds = [] %}
{% for category in allCategories %}
    {% set ancestorCatIds = ancestorCatIds|merge(category.ancestors.ids()) %}
{% endfor %}

{% set bottomCatIds = allCategories.ids()|without(ancestorCatIds) %}
{% set bottomCategories = craft.categories.id(bottomCatIds) %}

&lt;ul&gt;
    {% for category in bottomCategories %}
        &lt;li&gt;{{ macros.catBreadcrumbs(category) }}&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;


I made a macro that outputs the category breadcrumbs, to have even less logic in the output block.

{% macro catBreadcrumbs(category) %}
    {% set ancestorCategories = category.ancestors.find() %}
    {% set ancestorCategories = ancestorCategories|merge([category]) %}
    {{ ancestorCategories|join(' &gt; ') }}
{% endmacro %}