code: def used_states(self):
          'a list of the used states in the order they appear'
          c = itertools.count()
          canonical_ids = collections.defaultdict(lambda: next(c))
          for s in self.states_list:
              for state in s.stateseq:
                  canonical_ids[state]
          return list(map(operator.itemgetter(0),
                  sorted(canonical_ids.items(),key=operator.itemgetter(1)))f used_states(self):
          'a list of the used states in the order they appear'
          c = itertools.count()
          canonical_ids = collections.defaultdict(lambda: next(c))
          for s in self.states_list:
              for state in s.stateseq:
                  canonical_ids[state]
          return list(map(operator.itemgetter(0),
                  sorted(canonical_ids.items(),key=operator.itemgetter(1))))
docs: a list of the used states in the order they appear