While the platform allows the generation of objects based on other objects, it has no special means to analyze chains of related objects. We will provide a few tips on the subject that you can use in your development.
To form chains of related objects, add an auxiliary attribute to each generated object. The attribute will store a reference to the basis object. Then create a FilterCriterion object for filtering by specific values of that attribute.
Then, to get all generated objects, you can simply assign the required value to the filter criterion.