I´m struggling to do a linked list with a cypher statement. I´m trying to do the following for each k. The linked list and :NEXT relationship should be isolated by k.

```
match (elem:Event)<-[r:HAS_EVENT]-(k)
WITH elem ORDER BY elem.id ASC
WITH COLLECT(elem) AS elems
FOREACH (n IN RANGE(0, LENGTH(elems)-2) |
FOREACH (prec IN [elems[n]] |
FOREACH (next IN [elems[n+1]] |
MERGE (prec)-[:NEXT]->(next))))

```

Since it´s not possible to do a MATCH statement inside a FOREACH statement I tried MATCH (a:Some\_Label) with a as x UNWIND x as k and other possible ways to run this code by for each k (id lockup etc). I always end up with a long chain of :NEXT throu all :Event nodes, suggesting that the match statement considers all k nodes. I need help on how to match :Some\_Label nodes and pass each one of them to the above code.