def multi_match_aware_interval(k, delta, i, s, pi, li):
    """
    Function returning the interval of relevant substrings to lookup using the
    multi-match-aware substring selection scheme described in the paper.

    Args:
        k (int): Levenshtein distance threshold.
        delta (int): Signed length difference between both considered strings.
        i (int): k + 1 segment index.
        s (int): string length.
        pi (int): k + 1 segment position in target string.
        li (int): k + 1 segment length.

    Returns:
        tuple: start, stop of the interval.

    """
    start1 = pi - i
    end1 = pi + i

    o = k - i

    start2 = pi + delta - o
    end2 = pi + delta + o

    end3 = s - li

    return max(0, start1, start2), min(end1, end2, end3)