l have class that have parent and child with same class, and I don't know how many levels there are, i want to get id of last child
class Model
{
public Model Parent {get;set;}
public List<Model> Child {get;set;}
public string modelId {get;set;}
public bool HasChild {get;set;}
}
I have tried this way
var modelIds = Models.Where(e=>!e.HasChild).Select(e=>e.ModelId).ToList()
i cant find a way to get the last modelId