'This function should only be used internally
See Set._intersect for docstring'

def _intersect(self, other):

    if other.is_EmptySet:
        return other
    if (not other.is_Interval):
        return None
    infty = (S.NegativeInfinity, S.Infinity)
    if (self == Interval(*infty)):
        (l, r) = (self.left, self.right)
        if (l.is_real or (l in infty) or r.is_real or (r in infty)):
            return other
    if (not self._is_comparable(other)):
        return None
    empty = False
    if ((self.start <= other.end) and (other.start <= self.end)):
        if (self.start < other.start):
            start = other.start
            left_open = other.left_open
        elif (self.start > other.start):
            start = self.start
            left_open = self.left_open
        else:
            start = self.start
            left_open = (self.left_open or other.left_open)
        if (self.end < other.end):
            end = self.end
            right_open = self.right_open
        elif (self.end > other.end):
            end = other.end
            right_open = other.right_open
        else:
            end = self.end
            right_open = (self.right_open or other.right_open)
        if (((end - start) == 0) and (left_open or right_open)):
            empty = True
    else:
        empty = True
    if empty:
        return S.EmptySet
    return Interval(start, end, left_open, right_open)
