<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __validate_enrollment_periods(self, enrollments):
 """Check for overlapped periods in the enrollments"""


        for a, b in itertools.combinations(enrollments, 2):

            max_start = max(a.start, b.start)
            min_end = min(a.end, b.end)

            if max_start < min_end:
                msg = "invalid GrimoireLab enrollment dates. " \
                      "Organization dates overlap."
                raise InvalidFormatError(cause=msg)

        return enrollments