In Cypher you can get path anchored on two nodes f.e.
match path=(a)-[r:rel*1..5]->(b)
where a.val = 1 and b.val = 2
return path
the question is how can I get paths that contain say node '(x) where x.val = 5' in the middle, instead of all paths
You can add to the where clause
to get paths through at least one node that has val=5