There is some macro that group all the shapes that are inside other big shape?

I have a lot of shapes that are inside others and I need to group all of them so I could nest for laser cutting. 

Doing this manually takes a lot of time so I'm searching for some macro, I'm trying to make one but I didn'to figure out how to select this shapes yet.