title: Cypher find path avoiding certain node types except at the start and end
body: <p>I have a graph with the following structure:</p>
  
  <p><code>(r:Region)-[:CONTAINS]-(s:Station)-[:IS_AT]-(t:TrackLocation)-[:IS_NEXT_TO]-(t:TrackLocation)</code></p>
  
  <p>I want to find the shortest path between two <code>Station</code>s, using only track locations. My current query is:</p>
  
  <p><code>match (s1:Station) where s1.crs = 'ADR' match (s2:Station) where s2.crs = 'NRW' match  p=shortestPath((s1)-[*1..1000]-(s2)) WHERE ALL (n IN nodes(p) WHERE NOT n:Region) return nodes(p)</code>.</p>
  
  <p>The problem is, a station can be at multiple TrackLocations; and sometimes the shortest path can go via an intermediate Station node if it thinks this is quicker than sticking to TrackLocations for the intermediate nodes. If I change the filter to <code>WHERE NOT n:Region AND NOT n:Station</code>, then of course it won't work because the start and end nodes are stations.</p>
  
  <p>Is there any way to adjust this query to do <code>(Station)-&gt; via track locations only -&gt;(Station)</code>?</p>