From a memory point of view, it seems that any instance of your class will have to filter everything recursively to figure out what the relationship is. It is burdensome.
I would recommend just giving your class a property similar to this (or something more complex, depending on what you want to accomplish):
public Nested parent;
This will turn it into a linked list. You can separately create a method outside the class that manages to find parents based on a limited set of parameters (for example, FindParentsOfNestedToCertainGeneration (int numOfGenerations, Nested child)). It will simply pass on to the child and raise the chain of parents to the βparentβ property.
source share