<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _principals(self):
 """Extracts all principals from IAM statement. Should handle these cases: "Principal": "value" "Principal": ["value"] "Principal": { "AWS": "value" } "Principal": { "AWS": ["value", "value"] } "Principal": { "Service": "value" } "Principal": { "Service": ["value", "value"] } Return: Set of principals """

        principals = set()
        principal = self.statement.get("Principal", None)
        if not principal:
            # It is possible not to define a principal, AWS ignores these statements.
            return principals

        if isinstance(principal, dict):

            if 'AWS' in principal:
                self._add_or_extend(principal['AWS'], principals)

            if 'Service' in principal:
                self._add_or_extend(principal['Service'], principals)

        else:
            self._add_or_extend(principal, principals)

        return principals