def _expand_merge_duplicates(self):
        log.info("Expand | Searching for duplicates in %d nodes %d edges",
                 len(self), len(self._edges))
        # Filter for nodes with no incoming sream and store them in
        # a cache where we can retriev all nodes that reference
        # the same tool quickly.
        #
        # To avoid complex comparisons between the options instances
        # between the nodes, we cache a options hash value for eadh node
        # here and use that one later for the comparison between
        # possible merge candidates
        node_hashes = {}
        tools_2_nodes = collections.defaultdict(set)
        for n in self.nodes():
            if not n.has_incoming_stream():
                opt_set = n._tool.options._get_value_set()
                node_hashes[n] = hash(opt_set)
                tools_2_nodes[n._tool._name].add(n)
        ## index all nodes without an incoming stream by their tool name
        merged = 0
        for nodes in [n for k, n in tools_2_nodes.iteritems()
                      if len(n) > 1]:
            # the nodes set contains all nodes that reference the
            # same tool
            # Group them by checking that their options are the same
            # hence its the same tool with the same configuration
            while nodes:
                n = nodes.pop()
                group = set([n] + [m for m in nodes if m != n and
                                   node_hashes[n] == node_hashes[m]])
                # remove the group from the node set
                # and add it to tue option groups that will be merged
                nodes = nodes - group
                size = len(group)
                if size > 1:
                    log.info("Expand | Merging node group with %d nodes", size)
                    merged += size
                    self._merge_all(group)
        log.info("Expand | Merged %d nodes", merged)
Clear variables stored in __context__. Run this function when a new version
dataset/ETHPy150Open thasso/pyjip/jip/pipelines.py/Pipeline._expand_merge_duplicates--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/chocolatey.py/_clear_context