correctly removes optgroups and detects existing optgroups in select-to list