As a debugging piece of code, this will set whatever object you point to as a wireframe, and leave the rest.
Prior to your loop:
and within your loop:
obj = objectEnd;
while (obj-- > 4)
dbSetObjectWireframe (obj, false);
obj = dbPickObject(dbMouseX(), dbMouseY(), 4, objectEnd);
dbSetObjectWireframe (obj, true);
Works for me... although the wireframes seem to not be showing correctly for scaled objects. But the dbPickObject() command seems to be working well in either case.
When you hide an object, the pick object command sees through it. So with your code there, it'll see it with one frame, then see whatever's behind it the next, and see what's behind that the next frame, etc.