Q:

Filtering Nodes in Neo4j Query

I need to join two different graphs.  I would like to apply additional criteria based on nodes in variable path in the join condition.  The below query works fine. 
query1 = 
match(a:iknode)-[*1..2]->(c:iknode)
match(d:flights17)-[r1]-(e:flights17)
where d.alias contains a.name return a,c

However, it returns extraneous records.  I need to apply some filters on the nodes appearing in [*1..2] part.  This also works. 
match p = (a:fbnode)-[*1..2]->(c:fbnode)
where a.name = 'flights' and ANY (x IN nodes(p) WHERE x.name in ['leaving'])
return nodes(p)

I tried the following which doesn't work:
match p = (a:iknode)-[*1..2]->(c:iknode) 
(d:flights17)-[r1]-(e:flights17)
where d.alias contains a.name and ANY (x IN nodes(p) WHERE x.name in type(r1))
set e.f =c.name

How can I rewrite the above query? 
One option is to get the results from the first query and then filter the results in a separate query (or python).  However, I would like to do it in the query itself.  ALL can be used in place of ANY.  I would also like to exclude the start and end nodes while filtering.  

A:

This works:
match(d:flights17)-[r1]-(e:flights17) match p = (a:iknode)-[*1..2]->(c:iknode)  where d.alias contains a.name and ANY (x IN nodes(p) WHERE x.name in ['leaving']) set e.f =c.name

This also works for eliminating start and end nodes.  nodes(p)[1..-1]  

