code: def __parse_identities(self, aliases, email_to_employer):
          self.__parse_aliases_stream(aliases)
          self.__parse_email_to_employer_stream(email_to_employer)
          for alias, email in self.__raw_aliases.items():
              uid = self._identities.get(email, None)
              if not uid:
                  uid = UniqueIdentity(uuid=email)
                  e = re.match(self.EMAIL_ADDRESS_REGEX, email, re.UNICODE)
                  if e:
                      identity = Identity(email=email, source=self.source)
                  else:
                      identity = Identity(username=email, source=self.source)
                  uid.identities.append(identity)
                  self._identities[email] = uid
              e = re.match(self.EMAIL_ADDRESS_REGEX, alias, re.UNICODE)
              if e:
                  identity = Identity(email=alias, source=self.source)
              else:
                  identity = Identity(username=alias, source=self.source)
              uid.identities.append(identity)
          for email in self.__raw_identities:
              if email in self._identities:
                  uid = self._identities[email]
              elif email in self.__raw_aliases:
                  canonical = self.__raw_aliases[email]
                  uid = self._identities[canonical]
              else:
                  uid = UniqueIdentity(uuid=email)
                  identity = Identity(email=email, source=self.source)
                  uid.identities.append(identity)
                  self._identities[email] = uid
              enrs = self.__raw_identities[email]
              enrs.sort(key=lambda r: r[1])
              start_date = MIN_PERIOD_DATE
              for rol in enrs:
                  name = rol[0]
                  org = self._organizations.get(name, None)
                  if not org:
                      org = Organization(name=name)
                      self._organizations[name] = org
                  end_date = rol[1]
                  enrollment = Enrollment(start=start_date, end=end_date,
                                          organization=org)
                  uid.enrollments.append(enrollment)
                  if end_date != MAX_PERIOD_DATE:
                      start_date = end_date