title: Grouping UNIONed Cypher Results
body: <p>I have a cypher query like this that works fine:</p>
  
  <pre><code>MATCH path = (start)-[]-(some)-[]-(path)-[]-(end)
  RETURN start, end, path
  UNION
  MATCH path = (start)-[]-(some)-[]-(other)-[]-(path)-[]-(end)
  RETURN start, end, path
  </code></pre>
  
  <p>The only problem is that in some cases the same <code>start</code> and <code>end</code> nodes may match both patterns resulting in duplicates (with respect to <code>start</code> and <code>end</code>). Is there a cypher way to </p>
  
  <p><code>RETURN DISTINCT start, end, COLLECT(path)</code></p>
  
  <p>for the result of a UNION? Something like a SQL subquery?</p>