Would it be possible the relation grate-grandparent/grate-grandchild in elasticsearch?

It should work, you will just need to make sure you set the routing parameter to always point to the highest-generation (in the 4 generation case, the great-grandparent) so that all documents related to each other are on the same shard.

However, as far a I know this is un-tested so you will need to perform your own tests to make this work.

You also need to bear in mind that you run the risk of having un-evenly balanced shards (number of documents on each shard differs greatly) with this approach especially if the number of children of each generation varies between great-grandparents. The more generations you have the more susceptible to this you will be.

Lastly, each generation has an overhead cost in memory use. To make the queries efficient we need to store a data structure in memory which identifies the parent documents of each generation. Each generation you add in your index will add a new data structure which will cost memory. Note that this memory is (effectively) linear with the number of documents on the shard and not with the number of parent documents at that level.