That's quite a bit of work... There are some built-in functionalities in the extraction tools, but probably not what you are looking for. Some of the optimizer/yield improvement tools can do similar actions, at least internally. I do not think you can access those through skill.
Unless you are looking to reverse engineer something unknown, I would suggest to have the designer add properties to subblock/components to help such a script. For example, in differential pairs, add properties on the transistors to tell what they match/group with, etc.