title: Unique elements inside each child element of XML based on condition
body: <p>My requirement is that there should be only one listingagent TAG for each role_type Primary inside each commercial tag. </p>
  
  <pre><code>&lt;deal&gt;
  &lt;commercial&gt;
  &lt;party&gt;&lt;/party&gt;
  &lt;party&gt;
  &lt;role_detail&gt;
      &lt;role_type&gt;Primary&lt;/role_type&gt;
  &lt;/role_detail&gt;
  &lt;listingagents&gt;
      &lt;listingagent&gt;1&lt;/listingagent&gt;
      &lt;listingagent&gt;2&lt;/listingagent&gt;
  &lt;/listingagents&gt;
  &lt;/party&gt;
  &lt;party&gt;
  &lt;role_detail&gt;
      &lt;role_type&gt;Secondary&lt;/role_type&gt;
  &lt;/role_detail&gt;
  &lt;listingagents&gt;
      &lt;listingagent&gt;1&lt;/listingagent&gt;
  &lt;/listingagents&gt;
  &lt;/party&gt;
  &lt;party&gt;&lt;/party&gt;
  &lt;/commercial&gt;
  &lt;commercial&gt;
  
  
  &lt;/commercial&gt;
  &lt;commercial&gt;
  
  
  &lt;/commercial&gt;
  &lt;/deal&gt;
  </code></pre>
  
  <p>If there are more than one I need to raise an error. </p>
  
  <p>The code I tried is as follows </p>
  
  <pre><code>var duplicates = doc.Descendants("Commercial")
                                      .Select(c =&gt; c.Descendants("listingAgent"))
                                      .GroupBy(c =&gt; c.ToString())
                                      .Where(g =&gt; g.Count() &gt; 1)
                                      .Select(g =&gt; g.First())
                                      .ToList();
  
  
   if (duplicates.Any(c =&gt; c.Count() &gt; 1))
  {
     //show error
  }
  </code></pre>