Selecting object under another object


the blocks with the checks on it is the ones who should have a true output since theyre under another block of the same type, but how do i do that?
i cant do it like this:
image
i need to see if the block is under another block without selecting the other blocks-