def _group_by_size(fl):
    """Group FileInfos by their size"""

    # Start by sorting
    fl.sort(key=lambda f: f['size'])

    begin, end, length = 0, 1, len(fl)
    groups = []

    while end < length:
        # Get bounds of same-size files
        while fl[begin]['size'] == fl[end]['size']:
            end += 1

        # Take the slice of same-size files
        group = tuple(fl[begin:end])
        groups.append(group)

        # Advance the slicer
        begin = end
        end += 1

    return groups