def _sub_expand(self, tags):
        entities = {}
        graph = self._build_graph(tags)
        for tag in tags:
            for entity_index in xrange(len(tag.get('entities'))):
                node_name = graph_key_from_tag(tag, entity_index)
                if not node_name in entities:
                    entities[node_name] = []
                entities[node_name] += [
                    tag.get('entities', [])[entity_index],
                    tag.get('entities', [])[entity_index].get('confidence'),
                    tag
                ]
        for clique in get_cliques(list(entities), graph):
            result = []
            for entity_name in clique:
                start_token = int(entity_name.split("-")[0])
                old_tag = entities[entity_name][2]
                tag = {
                    'start_token': start_token,
                    'entities': [entities.get(entity_name)[0]],
                    'confidence': entities.get(entity_name)[1] * old_tag.get('confidence', 1.0),
                    'end_token': old_tag.get('end_token'),
                    'match': old_tag.get('entities')[0].get('match'),
                    'key': old_tag.get('entities')[0].get('key'),
                    'from_context': old_tag.get('from_context', False)
                }
                result.append(tag)
            result = sorted(result, key=lambda e: e.get('start_token'))
            yield result