<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_default(self, check=False):
 """Get the default realm :param check: check correctness if True :type check: bool :return: Default realm of Alignak configuration :rtype: alignak.objects.realm.Realm | None """

        found = []
        for realm in sorted(self, key=lambda r: r.level):
            if getattr(realm, 'default', False):
                found.append(realm)

        if not found:
            # Retain as default realm the first realm in name alphabetical order
            found_names = sorted([r.get_name() for r in self])
            if not found_names:
                self.add_error("No realm is defined in this configuration! "
                               "This should not be possible!")
                return None
            default_realm_name = found_names[0]
            default_realm = self.find_by_name(default_realm_name)
            default_realm.default = True
            found.append(default_realm)

            if check:
                self.add_error("No realm is defined as the default one! "
                               "I set %s as the default realm" % default_realm_name)

        default_realm = found[0]
        if len(found) > 1:
            # Retain as default realm the first so-called default realms in name alphabetical order
            found_names = sorted([r.get_name() for r in found])
            default_realm_name = found_names[0]
            default_realm = self.find_by_name(default_realm_name)

            # Set all found realms as non-default realms
            for realm in found:
                if realm.get_name() != default_realm_name:
                    realm.default = False

            if check:
                self.add_warning("More than one realm is defined as the default one: %s. "
                                 "I set %s as the default realm."
                                 % (','.join(found_names), default_realm_name))

        self.default = default_realm

        return default_realm