def parse_filter_group(spec):
    """given the specification (a list of lines) continue parsing lines
       until the filter group ends, as indicated by the start of a new LABEL,
       (case 1), the start of a new section (case 2) or the end of the spec
       file (case 3). Returns a list of members (lines) that belong to the
       filter group. The list (by way of using pop) is updated in the calling
       function.

       Parameters
       ==========
       spec: unparsed lines of the deid recipe file
    """
    members = []
    keep_going = True
    while keep_going and spec:
        next_line = spec[0]
        if next_line.upper().strip().startswith('LABEL'):
            keep_going = False
        elif next_line.upper().strip().startswith('%'):
            keep_going = False
        else:
            new_member = spec.pop(0)
            members.append(new_member)
    return members
