Two changes: 1) return cfg without duplicate alternatives (while parsing the ambiguous output, do not duplicate alts); 2) function rename to reflect what it does: find the cfg subset that is ambiguous