def _collapse_subdrivers(self, g):
        """collapse subdriver iteration sets into single nodes."""
        # collapse all subdrivers in our graph
        itercomps = {}

        for child_drv in self.subdrivers(recurse=False):
            itercomps[child_drv.name] = [c.name for c in child_drv.iteration_set()]

        for child_drv in self.subdrivers(recurse=False):
            excludes = set(self._iter_set)
            for name, comps in itercomps.items():
                if name != child_drv.name:
                    for cname in comps:
                        if cname not in itercomps[child_drv.name]:
                            excludes.add(cname)

            collapse_driver(g, child_drv, excludes)

        # now remove any comps that are shared by subdrivers but are not found
        # in our workflow
        to_remove = set()
        for name, comps in itercomps.items():
            for comp in comps:
                if comp not in self._iter_set:
                    to_remove.add(comp)

        g.remove_nodes_from(to_remove)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/driver.py/Driver._collapse_subdrivers/original