If you trying to make groups of the same objects, add a private variable called 'group id' or something, and when you create say 4 soldiers, give them a number (such as a global variable that you can incriment).
Then if you need to select a group, you can just compare the private variable. I'd also recommend adding a family because then you can do stuff like this:
On left click soldier
FamilySoldier - Select all with 'groupid' equal to soldier('group id')
And then FamilySoldier will be all the soldiers in the group, and soldier will be the one you actually clicked on