py2neo expand graph by accessing nodes from execute() record
<p>As I have learnt from another question it is apparently not possible in Cypher alone to copy a subgraph or to duplicate a chain of nodes. But I need to do this somehow. Therefor I looked for a more hacky approach to do this.</p>

<p>Specifically I need to transform am graph that looks like this:</p>

<pre><code>(A)──&gt;(N1:T1)──&gt;(B)
</code></pre>

<p>into a graph that looks like this</p>

<pre><code>(A)──&gt;(N1:T1)──&gt;(B)
 │               ^
 └───&gt;(N2:T2)────┘
</code></pre>

<p>Though the part between <code>A</code> and <code>B</code> can be arbitrarily long. What matters is that all nodes of type <code>T1</code> get converted to type <code>T2</code> in the <em>copy</em> of the original path (the one with <code>N1</code> in the example).</p>

<p>So, if I have for example this graph:</p>

<pre><code>MERGE (N1:A)-[:r]-&gt;(N2:B)-[:r]-&gt;(N3:C)
MERGE (N1)-[:r]-&gt;(N4:C)-[:r]-&gt;(N5:C)
</code></pre>

<p>and a query that looks like this:</p>

<pre><code>MATCH p=(:A)-[*0..]-&gt;(:B)-[*0..]-&gt;(:C)
RETURN p
</code></pre>

<p>and I execute it with <code>graph.cypher.execute(&lt;query&gt;)</code> then the record returned by <code>execute()</code> is:</p>

<pre><code>   | p                         
---+----------------------------
 1 | (:A)-[:r]-&gt;(:B)-[:r]-&gt;(:C)
</code></pre>

<p>Now I would like to get the IDs of all the nodes. Then I could generate a string with Cypher code that represents the copied path and execute it again with <code>execute()</code>. And in that string I would use the IDs of nodes in the record to connect to the existing nodes in the database. But I recall that it is somehow not possible either, to target nodes in the database from outside via an ID... or is in fact it possible? Are there any other ways I could go about this? Somebody mentioned the <code>dump</code> functionality, but the documentation is very lacking on that and I don't quite understand how it is supposed to work. And in addition I am not even sure if it does what I need.</p>