title: Neo4j Cypher: How do you unpack nodes from a path to allow for further matching?
body: <p>This question is a follow on to the question <a href="https://stackoverflow.com/questions/22143839/neo4j-cypher-terminating-conditions-when-using-variable-level-paths/22146368">here</a></p>
  
  <p>I have a graph that has a circular linked list. (<a href="http://neo4j-console-20.herokuapp.com/?id=do6art" rel="noreferrer">see here for an example</a>) Each node in the linked list points to a User. When querying the list I have to use a path statement as the list is circular and I do not want to retrieve nodes beginning from the u:USER node. In order to get the nodes of interest my query looks like this:</p>
  
  <pre><code>MATCH path=(nl:NODELINK { linkId:'cc' })-[:LINK*]-&gt;(u:USER)
  RETURN nodes(path)
  </code></pre>
  
  <p>Once I have retrieved the path I would like to do further matching against the nodes in that path (the NODELINK's), somthing like the following:</p>
  
  <pre><code>MATCH path=(nl:NODELINK { linkId:'cc' })-[:LINK*]-&gt;(u:USER)
  WITH nodes(path) AS nodeLinks
  MATCH nodeLinks-[:PERSONLINK]-&gt;persons
  RETURN persons
  </code></pre>
  
  <p>but if I try I get an error:</p>
  
  <pre><code>Error: Type mismatch: nodeLinks already defined with conflicting type Collection&lt;Node&gt; (expected Node) (line 3, column 7)
  "MATCH nodeLinks-[:PERSONLINK]-&gt;persons"
  </code></pre>
  
  <p>How do I unpack the nodes of type NODELINK from the path in order to do further MATCH queries against them?</p>