I would just get the middle from the rectangle and do a pick at this point with dynamic radius. sure the selection is not a real rectangle but I think this would be superfast. then you can pptimize the script when you calculate that the entity is not in the rectangle with checking x1 x2, z1 z2
so you have a circle selection and delete "wrong" picked entities.