Replace Detail Groups in a project

Hi Members,

I have got a situation,

I am trying to replace Detail groups in a project though dynamo and I can’t really find any proper way to do it. Has anyone dealt with this situation before?

There are 30 Groups in a project, and they are placed in a view.
I need to update those groups, There is no way we can edit the group through dynamo so my approach is, un-group one of the instances and modify that and create a new group and replace the rest of them with the new group. I have managed to do the first bit but now struggling to place those groups in the view.

Any suggestions?
Thank you