If loop contains id `X` Is it possible to check a matrix array for an ID?

I created a entries field which functions as a navigation.
Now if the user decides to remove one entry I want the specific template to return a 404



I thought something like (Assuming we are in the "Journalismus" template):

{% for navi in navigation.navi %}
    {% if '4' not in navi.id %}
        {% exit 404 %}
    {% endif %}
{% endfor  %}


But that does pass the 404 always.

Or is there a better way to do this?
{% if '4' not in navigation.navi.ids() %}
    {% exit 404 %}
{% endif %}