title: Neo4j match nodes related to all nodes in collection
body: <p>I have a graph of tags, which are related with each other. My goal is to create a Cypher query, which will return all tags that are related to an array of input tags via 1 or 2 hops.</p>
  
  <p>I made a query, which doesn't work quite as intended.</p>
  
  <pre><code>MATCH (t:Tag)
  WHERE t.name IN ["A", "B", "C"]
  WITH t
  MATCH (a:Tag)-[:RELATED*1..2]-(t)
  RETURN DISTINCT a;
  </code></pre>
  
  <p>This query first finds the nodes <code>A</code>, <code>B</code>, <code>C</code> and then searches for tags, that are related to <code>A</code>, <code>B</code> <strong>or</strong> <code>C</code> via 1 node or less.</p>
  
  <p>What I want to do though is to find tags, which are related to ALL three nodes (<code>A</code>, <code>B</code> <strong>and</strong> <code>C</code>).</p>
  
  <hr>
  
  <p>I know I could concatenate <code>MATCH</code> and <code>WITH</code> statements, and do something like this:</p>
  
  <pre><code>MATCH (t:Tag)-[:RELATED*1..2]-(a:Tag)
  WHERE t.name="A"
  
  WITH DISTINCT a
  MATCH (t:Tag)-[:RELATED*1..2]-(a)
  WHERE t.name="B"
  
  WITH DISTINCT a
  MATCH (t:Tag)-[:RELATED*1..2]-(a)
  WHERE t.name="C"
  ...
  RETURN DISTINCT a;
  </code></pre>
  
  <p>But it runs painfully slow, when the number of input tags increase (in this case only 3 input tags: <code>A</code>, <code>B</code>, <code>C</code>).</p>
  
  <hr>
  
  <p>So is there a way to make it in one query, similar to my first try?</p>