For loop that can accept array and element query without throwing .all deprecation error
Instead of trying to loop through an object (your Query) you could just execute it

{% set component = {
    headline: headline ?? entry.headline ?? null,
    body: body ?? entry.body ?? null,
    items: items ?? entry.items.all() ?? null
} %}

&lt;h1&gt;{{ component.headline }}&lt;/h1&gt;
&lt;p&gt;{{ component.body }}&lt;/p&gt;

{% for item in component.items %}
    {{ item.name }}
{% endfor %}


or if that doesn't fit your case, you can do it before

{% set relatedEntry = entry.callToAction.one() %}
{% include '_components/callToAction' with {
    entry: relatedEntry,
    items: relatedEntry.items.all()
} %}


You could as well check if your variable is an object of type EntryQuery

{% if className(entry) == 'craft\elements\db\EntryQuery' %}
    {% set entry = entry.one() %}
{% endif %}


Note: since you had multiple of these deprecated errors I wasn't exactly sure which one you wanted to "solve" and which one is "intended"