title: neo4j cypher: stacking results with UNION and WITH
body: <p>I'm doing a query like</p>
  
  <pre><code>MATCH (a)
  WHERE id(a) = {id}
  
  WITH a
  
  MATCH (a)--&gt;(x:x)--&gt;(b:b)
  
  WITH a, x, b
  
  MATCH (a)--&gt;(y:y)--&gt;(b:b)
  
  WITH a, x, y, b
  
  MATCH (b)--&gt;(c:c)
  
  RETURN collect(a), collect(x), collect(y), collect(b), collect(c)
  </code></pre>
  
  <p>what I want here is to have the <code>b</code> from <code>MATCH (a)--&gt;(y:y)--&gt;(b:b)</code> to be composed of the ones from that line and the ones from the previous <code>MATCH (a)--&gt;(x:x)--&gt;(b:b)</code>. The problem I'm having with <code>UNION</code> is that its picky about the number and kind of nodes to be passed on the next query, and I'm having trouble understanding how to make it all go together.</p>
  
  <p>What other solution could I use to merge these nodes during the query or just before returning them? (Or if should I do it with <code>UNION</code> then how to do it that way...)</p>
  
  <p>(Of course the query up there could be done in other better ways. My real one can't. That is just meant to give a visual example of what I'm looking to do.)</p>
  
  <p>Much obliged!</p>