That was clear from the beginning.
No. I mean the first aggregation. You did not really shared the pipeline so I will try to illustrate my question.
Is FirstCollection the same as A or B or is it a third one that is not A nor B? If it is a third one, then an idea that might work is that you create an on-demand materialized view from the first 5 stages. The you could $merge the materialized into A, and then start an aggregation on the materialized view with step-6 that you would merge into B.
This way step-1 to step-5 are executed only once when the materialized view is created.