How to join nested embedded documents from different collectionsdynamically

Continuing the discussion from How to do embedded documents using spring java mongo repository:

In the above thread the answer we are manually joining the by mentioning the path of fields. But I have more than 8 nested categories. How can join/refrence the documents at various level dynamically.

@007_jb can you please help here

You’re having a schema design nightmare. Sounds like you inherited this database? I’m still suggesting a redesign.

Please expand with examples of what you’re trying to achieve.