A question about collisions: python or nodes?

I’ve been coding in Python for a few years now and recently got into using Blender for doing some data visualisations, when I started looking into trying to produce some simulations especially where collision detection is needed I came across UPBGE. This look like the answer to my challenge and so now trying to figure out the best way to go about it is where I call upon your assistance.

The objective is that when two objects collide a variable assigned to each object is updated (the object with the higher value sets lower value object to its value). The value of the variable drives the colour of the object.

I have been trying to find a working example of a bit of code that shows how to use the collision detection class (I’m probably not using the correct search criteria) but not having much success. I’ve managed to use the nodes to trigger actions and I suspect what I want to do is combination of using the nodes and python which is fine with me, whatever works.

Any guidance is very much appreciated.