def check_enclosing(ch2peaks):
    """
Given a dictionary of peaks, check if there is some peak completely enclosed by
another one.

ch2peaks = { chrom: [(start, end, ...), ...], ... }, where peaks for each
chromatin have been sorted based on (start, end), and each start coordinate must
be strictly less than the corresponding end site.

If that's the case, return (True, (start1, end1, ...), (start2, end2, ...)),
where the 1st peak is enclosed by the 2nd. Otherwise, return
(False, None, None).

"""
    pre = None
    for ch in ch2peaks:
        peaks = ch2peaks[ch]
        if len(peaks) == 0:
            continue
        s, e = peaks[0][:2]
        s -= 1
        e -= 1
        for peak in peaks:
            start, end = peak[:2]
            if start == s:
                return True, pre, peak
            if end <= e:
                return True, peak, pre
            pre = peak
            s, e = start, end
    return False, None, None
