IID actually is a perfect fit for what you are attempting to do it seems.
They automatically ID an instance of an object type. If you delete the instance and then create a new instance of the same object, this object will have the "missing" ID without you having to check whether it was existing or not in the first place.
Another solution I'd go along with, in the case where I'd want to handle my order system as you seem to be willing to do is using an array.
The index of the array acts as "GroupID" and the value of the array would be the UID of the "Group".
When creating the array, make it as wide as you already have Group in your layout. At worst, start it at width 0 and push a new index for each group this way you can assign an index and the UID in the array.
When deleting a Group instance, check in the array the index for the UID you are currently deleting, and modify the value from the UID to something like -1.
This would be your "empty" value.
When creating an instance, you would go through the array to check whether you have -1 values or not. If you do, place the UID value in this index. If you don't, push a new index.
The array would then grow dynamically when the "max amount" is reached, but otherwise would allow you to use existing indexes.
Using functions to automate looping through the array would be of help.
But again, you are basically trying to redo the IID system.