def __parse_organizations(self, stream):
        """Parse organizations stream"""

        for aliases in self.__parse_stream(stream):
            # Parse identity
            identity = self.__parse_alias(aliases[1])
            uuid = identity.email

            uid = self._identities.get(uuid, None)

            if not uid:
                uid = UniqueIdentity(uuid=uuid)
                identity.uuid = uuid
                uid.identities.append(identity)
                self._identities[uuid] = uid

            # Parse organization
            mailmap_id = aliases[0]
            name = self.__encode(mailmap_id[0])

            if name in MAILMAP_NO_ORGS:
                continue

            org = Organization(name=name)
            self._organizations[name] = org

            enrollment = Enrollment(start=MIN_PERIOD_DATE, end=MAX_PERIOD_DATE,
                                    organization=org)
            uid.enrollments.append(enrollment)
Parse organizations stream