Because you're going through the client group, and then going through objects attached to the client, which will be nothing.
for(%a = 0; %a < mainBrickGroup.getCount(); %a++)
{
%bg = mainBrickGroup.getObject(%a);
for(%b = 0; %b < %bg.getCount(); %b++)
{
%brick = %bg.getObject(%b);
// Do Stuff
}
}