def __parse_organizations(self, stream):
        if not stream:
            return
        yaml_file = self.__load_yml(stream)
        try:
            for element in yaml_file:
                name = self.__encode(element['organization'])
                if not name:
                    error = "Empty organization name"
                    msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
                    raise InvalidFormatError(cause=msg)
                o = Organization(name=name)
                if 'domains' in element:
                    if not isinstance(element['domains'], list):
                        error = "List of elements expected for organization %s" % name
                        msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
                        raise InvalidFormatError(cause=msg)
                    for dom in element['domains']:
                        if dom:
                            d = Domain(domain=dom, is_top_domain=False)
                            o.domains.append(d)
                        else:
                            error = "Empty domain name for organization %s" % name
                            msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
                            raise InvalidFormatError(cause=msg)
                self._organizations[name] = o
        except KeyError as e:
            error = "Attribute %s not found" % e.args
            msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
            raise InvalidFormatError(cause=msg)
        except TypeError as e:
            error = "%s" % e.args
            msg = self.GRIMOIRELAB_INVALID_FORMAT % {'error': error}
            raise InvalidFormatError(cause=msg)