Given an open BED file, yield tuples of (`chrom`, `chrom_iter`) where
    `chrom_iter` yields tuples of (`start`, `stop`).

def _bed_iter(bed):
    """
    Given an open BED file, yield tuples of (`chrom`, `chrom_iter`) where
    `chrom_iter` yields tuples of (`start`, `stop`).
    """
    records = (line.split()[:3] for line in bed if
               not (line.startswith('browser') or line.startswith('track')))

    for chrom, chrom_iter in itertools.groupby(records, lambda x: x[0]):
        yield chrom, ((int(start), int(stop))
                      for _, start, stop in chrom_iter)