<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def delete(self, organization, domain=None):
 """Remove organizations and domains from the registry. The method removes the given 'organization' or 'domain' from the registry, but not both at the same time. When 'organization' is the only parameter given, it will be removed from the registry, including those domains related to it. When 'domain' parameter is also given, only the domain will be deleted. 'organization' must exists in the registry prior removing the domain. :param organization: name of the organization to remove :param domain: domain to remove from the registry """

        if not organization:
            return CMD_SUCCESS

        if not domain:
            try:
                api.delete_organization(self.db, organization)
            except NotFoundError as e:
                self.error(str(e))
                return e.code
        else:
            try:
                api.delete_domain(self.db, organization, domain)
            except NotFoundError as e:
                self.error(str(e))
                return e.code

        return CMD_SUCCESS