'Process indices with Ellipsis. Returns modified index.'

def _check_ellipsis(self, index):

    if (index is Ellipsis):
        return (slice(None), slice(None))
    elif isinstance(index, tuple):
        for (j, v) in enumerate(index):
            if (v is Ellipsis):
                first_ellipsis = j
                break
        else:
            first_ellipsis = None
        if (first_ellipsis is not None):
            if (len(index) == 1):
                return (slice(None), slice(None))
            elif (len(index) == 2):
                if (first_ellipsis == 0):
                    if (index[1] is Ellipsis):
                        return (slice(None), slice(None))
                    else:
                        return (slice(None), index[1])
                else:
                    return (index[0], slice(None))
            tail = ()
            for v in index[(first_ellipsis + 1):]:
                if (v is not Ellipsis):
                    tail = (tail + (v,))
            nd = (first_ellipsis + len(tail))
            nslice = max(0, (2 - nd))
            return ((index[:first_ellipsis] + ((slice(None),) * nslice)) + tail)
    return index
