title: Linq infinite nested query
body: <p>I need to get a node of a nested collection looking through It's deep with linq.</p>
  
  <p>This is the nested class:</p>
  
  <pre><code>public class Group
  {
  
      public int Id { get; set; }
  
      public string Description { get; set; }
  
      public int ParentId { get; set; }
  
      public List&lt;Group&gt; Groups { get; set; }
  
  }
  </code></pre>
  
  <p>Each instance of this class can have multiple instances inside the Groups method and so on. Each instance is linked through the ParentId property.</p>
  
  <p>I need, having an instance of Group class, retrieve his father. I tried with this:</p>
  
  <pre><code>var parent = _repositoryGroups
  .Where(g =&gt; g.Id == [my Group instance].ParentId)
  .SelectMany(g =&gt; g.Groups)
  .FirstOrDefault()
  </code></pre>
  
  <p>I don't know why, but not always it find the father instance and It starts looking from the second level (but this is not a real problem).</p>
  
  <p>What's the best way to find the element through all the deep of this nested class?</p>
  
  <p>Thanks</p>