Grouping nodes

I wish to retrive all the events that happens in the same time and my idea is to find the event based on the start time and end time, I write a stupid code which is not efficient and seems a mass, therefore I would to ask if there is a smart way of retrieve the co-evolving events?


MATCH (c:Car {carID:"car_ID"})-[:takePlace]->(e:Event)
with collect(e) as cles

UNWIND cles as cle
match (c:Car {carID:"car_ID"})-[:takePlace]->(e:Event)
where (e.start_time in range(cle.start_time, cle.end_time)) and (e.end_time in range(cle.start_time, cle.end_time))
with collect(e) as coll
return cle, coll

This worked for me.
I am not grouping them yet but you can add that.
It shows the events that are happening within the start and end of a different event.

MATCH (e1:Event)
MATCH (e2:Event)
where id(e1)<>id(e2)
WITH e1, e2, Case when e1.start >= e2.start AND e1.end <= e2.end then 'between' else 'not between' END as within
//where within = 'between'
Return,, apoc.text.format("%s-%s is %s %s-%s.", [e1.start,e1.end,within,e2.start,e2.end]) as results

Results: results
b a 2-3 is between 1-10.
b c 2-3 is between 2-5.
c a 2-5 is between 1-10.
d a 7-9 is between 1-10.
d f 7-9 is between 4-9.
e a 9-10 is between 1-10.
f a 4-9 is between 1-10.

My test data:

id start end
a 1 10
b 2 3
c 2 5
d 7 9
e 9 10
f 4 9

To load up test data:

create (a:Event), (b:Event), (c:Event), (d:Event), (e:Event), (f:Event)
a.start = 1, a.end = 10, = 'a',
b.start = 2, b.end = 3, = 'b',
c.start = 2, c.end = 5, = 'c',
d.start = 7, d.end = 9, = 'd',
e.start = 9, e.end = 10, = 'e',
f.start = 4, f.end = 9, = 'f'
return a, b, c, d, e, f

I hope that helps.