def bedslice(grouped, chrom, start, end):
    """Assumes no proper nesting of intervals"""
    chromdf = grouped.get_group(chrom)
    lo = chromdf['end'].values.searchsorted(start, side='right')
    hi = None if end is None else lo + chromdf['start'].values[lo:
        ].searchsorted(end, side='left')
    return chromdf.iloc[lo:hi]
