Assigning properties values based on lists

Dear neo4j community,

I'm seeking to your help as I have worked a lot on the following problem with finding appropriate solution.

I have a network with certain circuits , the circuit is define as a group of nodes with makes the path so for example if I have circuit X that is going from point A to point Z the nodes (hops) are the path A-B-C-Z . The goal is to assign a point type for each of the hops so for example point A will be start point Z will be END and the other points in between are middle. I have a property called link_index that gives that order. I have tried to right query to got those indexes as lists and then loop over elements on those list to assign values accordingly but that never worked. Below are my trials:

MATCH (m:Route) WITH max(distinct(m.Date_ID)) as m_recent MATCH (n:Route {Date_ID: m_recent})
MATCH (a)<-[:CONNECTS]-(link)-[:CONNECTS]->(z)
WHERE l.Date_ID = m_recent AND a >  z and l.Route_ID contains "Circuit-A"
WITH a,z,l, m_recent order by l.Link_Index asc
OPTIONAL MATCH (r:Route)<-[CB]-(l)
WITH l,collect(DISTINCT (l.Link_Index)) AS seq, COLLECT(DISTINCT(l.Route_ID)) AS routes   
WITH max(seq) as max ,routes,l
UNWIND range(0,size(routes)) AS i     
match (r:route{Route_ID:routes[i]})
WHEre l.Link_Index=max
set  l.point_Type="END"
return  l

That never returns any value , I'm having the filter contains on one circuit just to work on one example as a start. My issue is with this line

WITH l,collect(DISTINCT (l.Link_Index)) AS seq, COLLECT(DISTINCT(l.Route_ID)) AS routes 

it cant return both list and nodes to filter over the list per node. Please let me know if my explanation is not clear, I have been working on this query for so long with no luck

Perfect Query will do the following:

1- Get All indexes per circuit and have them as list
2- at each circuit assign the type based on the index
Start --> First element on the list
END --> Last element on the list
Middle --> all other hops