Hello GUICAD
As I'm not an expert with scripting, I checked with my Team on this and here is a sample script that identifies bodies based on location either root or components and then moves them to root and reorganize with the volume of the body. (check image)
You may take ideas from this and maybe develop a script to identify the body based on face selection.
Please let me know if you need further guidance on this?