Creating Visual Sorting Task - Check for Piles

Hello. I am trying to create a visual sorting task in PyschoPy. So far I have used code from the forum to make the 16 images click and draggable. What I am unsure about is how to code the program so that it checks whether two images are touching and then label that a pile. From there it would check for more images that were added to the pile and check for the creation of new piles. Additional details: there are no right answers, so every participants piles can be different. A pile is a min. two images and a max. eight images.

Below is an screen shot of the program so far. What I would appreciate some help with is where to start writing the code to check that two images are touching and when true these two images form a pile (i.e. list with the images in it), an example, or relevant documentation. So far reading about collision and overlap has not moved the needle towards any working example. I understand that this will need to be tested repeatedly as it is built.

Thanks for your attention.