<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def privatesuffix(self, domain, accept_unknown=None):
 """ Return shortest suffix assigned for an individual. domain: str or unicode to parse. (Required) accept_unknown: bool, assume unknown TLDs to be public suffix. (Default: object default) Return None if domain has invalid format. Return None if domain has no private part. """


        if accept_unknown is None:
            accept_unknown = self.accept_unknown

        if not isinstance(domain, basestr):
            raise TypeError()

        labels = domain.lower().rsplit(".", self._maxlabel + 2)
        ll = len(labels)

        if "\0" in domain or "" in labels:
            # not a valid domain
            return None

        if ll <= 1:
            # is TLD
            return None

        # skip labels longer than rules
        for i in range(max(0, ll - self._maxlabel), ll):
            s = ".".join(labels[i:])

            if i > 0 and ("!*." + s) in self._publicsuffix:
                return ".".join(labels[i-1:])

            if ("!" + s) in self._publicsuffix:
                # exact private match
                return s

            if i > 0 and ("*." + s) in self._publicsuffix:
                if i <= 1:
                    # domain is publicsuffix
                    return None
                else:
                    return ".".join(labels[i-2:])

            if s in self._publicsuffix:
                if i > 0:
                    return ".".join(labels[i-1:])
                else:
                    # domain is publicsuffix
                    return None

        else:
            # no match found
            if self.accept_unknown and ll >= 2:
                return ".".join(labels[-2:])
            else:
                return None