Make unique separate groups

Please, is it possible to do this only for the selection you make.!
Thanks.!

Edit: The extension from your link doesn’t work for nested groups, so a ruby command would be better.!