code: private BooleanClause createBooleanClause(Query query, Occur occur) {
          if (query instanceof BooleanQuery) {
              BooleanClause[] clauses = ((BooleanQuery) query).getClauses();
              if (clauses.length == 1
                      && clauses[0].getOccur().equals(Occur.MUST_NOT)) {
                  return clauses[0];
              }
          }
          return new BooleanClause(query, occur);
      }
docs: If the query is a BooleanQuery and it contains a single Occur.MUST_NOT
  clause it will be returned as is. Otherwise it will be wrapped in a
  BooleanClause with the given Occur.