def distinct(self):
        """Extracts distinct history events based on their types

        :rtype: list of swf.models.event.Event
        """
        distinct_events = []

        for key, group in groupby(self.events, lambda e: e.type):
            g = list(group)

            # Merge every WorkflowExecution events into same group
            if (len(g) == 1 and
                len(distinct_events) >= 1 and
                    g[0].type == "WorkflowExecution"):
                # WorfklowExecution group will always be in first position
                distinct_events[0].extend(g)
            else:
                distinct_events.append(list(g))

        return distinct_events