Dynamo python script - For loop, colliding objects

I’m working on a script where each object should check if it is colliding with any other object. I have a single list of all the objects and a function which can determine if two objects are colliding and delete one of the items. Is it possible to make this script work inside of Dynamo?

for i,obj1 in enumerate(list1):
for j in range(i+1,len(list1)):
obj2 = list1[j]
if collide(obj1,obj2):
obj1.keep()
obj2.delete()

for i,obj1 in enumerate(list1):
for j in range(i+1,len(list1)):
obj2 = list1[j]
if collide(obj1,obj2):
obj1.keep()
obj2.delete()

Do you have script? some example? use OUT and IN[0]

I think Syntex is still incomplete!

RK

Andreas