@Nullable
  private static PackageSet processComplementaryScope(@NotNull PackageSet current,
                                                      PackageSet added,
                                                      boolean checkComplementSet,
                                                      boolean[] append) {
    final String text = added.getText();
    if (current instanceof ComplementPackageSet &&
        Comparing.strEqual(((ComplementPackageSet)current).getComplementarySet().getText(), text)) {
      if (checkComplementSet) {
        append[0] = false;
      }
      return null;
    }
    if (Comparing.strEqual(current.getText(), text)) {
      if (!checkComplementSet) {
        append[0] = false;
      }
      return null;
    }

    if (current instanceof UnionPackageSet) {
      PackageSet[] sets = ((UnionPackageSet)current).getSets();
      PackageSet[] processed = ContainerUtil.mapNotNull(sets, s -> processComplementaryScope(s, added, checkComplementSet, append), new PackageSet[0]);
      return processed.length == 0 ? null : UnionPackageSet.create(processed);
    }

    if (current instanceof IntersectionPackageSet) {
      PackageSet[] sets = ((IntersectionPackageSet)current).getSets();
      PackageSet[] processed = ContainerUtil.mapNotNull(sets, s -> processComplementaryScope(s, added, checkComplementSet, append), new PackageSet[0]);
      return processed.length == 0 ? null : IntersectionPackageSet.create(processed);
    }

    return current;
  }
@Nullable
  private static PackageSet processComplementaryScope(@NotNull PackageSet current,
                                                      PackageSet added,
                                                      boolean checkComplementSet,
                                                      boolean[] append)