Check children on a grid

Hey there! I have a little problem… I have a grid, and it works like Lego, you can move lego pieces and snap it at one place with Spacebar. But I have a little problem. Im checking if the block that im moving right now is at other blocks position move it along Z axis, so the lego pieces stack at themselves, like a tower. This works, but when I place a block next to the tower, and than when I move the next block again at the tower, it just goes inside. Something like this

I have this

ooooo // its from the side

than i make a tower of …lets say 3 blocks, and dont mind the ball at the left,

 •  
   •
   •
ooo•o

it works, now when i place a block next to the tower

 •       
   •
   •
oo••o

now its spawns another block, and when i move it right again, into the tower, it dont goes on top if it, but into it like this

 •     
   •
   •
oo•xo //x is the block that went into the tower

Source code is this.

Already figured out…I made it bit else from the root, and it works perfectly.