The top or the bottom, depends on the order you draw it, by the way you are displaying the circles, the order is 1 , 2 , 3 , 4, so 4 will be always at top.
Lets suppose that you put a random number, so we can’t know which one is on the top, maybe you can put a variable counter in your class that will be increasing anytime you are creating a new object and, in that way, check which one is on the top…
Or just put a variable height and draw the objects depending on that height, in a specific order.
There are many ways of do it I think, take the one you are more comfortable
You don’t have to do the is over check in the same loop. You can do it in an separate loop (a) previous to yours (b, the one that you have now). Store the result in a and evaluate it in b.