In answer to previous questions was shown how to collect documents under their collection names but there was a clear constraint that query returns only one document for each collection.
@CoDEmanX asked what if the query returns many documents of the same collection?