title: How to distinct groups of values?
body: <p>I am trying to build a query that select unique groups of values. I know how to group values and select distinct values, but I don't see how to select distinct groups of values regarless of the order of the elements considered. More precisely:</p>
  
  <p>My XML is something like this:</p>
  
  <pre><code>&lt;A&gt;
      &lt;B type="1"&gt;value1&lt;/prop&gt;
      &lt;B type="2"&gt;value2&lt;/prop&gt;
      &lt;B type="3"&gt;value3&lt;/prop&gt;
      &lt;B type="4"&gt;value4&lt;/prop&gt;
  &lt;C&gt;
      &lt;D&gt;XXX&lt;/D&gt;
  &lt;/C&gt;
  &lt;C&gt;
      &lt;D&gt;YYY&lt;/D&gt;
  &lt;/C&gt;
  &lt;/A&gt;
  
  &lt;A&gt;
      &lt;B type="3"&gt;value3&lt;/prop&gt;
      &lt;B type="4"&gt;value4&lt;/prop&gt;
      &lt;B type="2"&gt;value2&lt;/prop&gt;
  &lt;C&gt;
      &lt;D&gt;XXX&lt;/D&gt;
  &lt;/C&gt;
  &lt;C&gt;
      &lt;D&gt;YYY&lt;/D&gt;
  &lt;/C&gt;
  &lt;/A&gt;
  </code></pre>
  
  <p>Here I would like to make groups of <code>&lt;B&gt;</code> values from all <code>&lt;A&gt;</code> nodes and select only unique sets of values. For instance, here:</p>
  
  <p>value1+value2+value3+value4 </p>
  
  <p>and</p>
  
  <p>value2+value3+value4+value1</p>
  
  <p>These two sets of values should be only unique if some or all of the values are different.</p>
  
  <p>Thank you very much in advance for your help. </p>