Easiest way to count bodies in area

hi guys

what's the best/easiest way to count all bodies that lay down on the top of other body. i have 2 count all red ones.
Image


boxes are showing in random numbers and not every box is touching big (green) box.
You can get the contacts and perform a Depth First Search. The island generator in Box2D does this too, so you can start with that code.

Original thread: https://box2d.org/forum/viewtopic.php?t=8295