private Object negate(String key, Document value) {
        if (value.size() == 1) {
            return asDocument(key, asDocument("$not", value));

        } else {
            List<Object> list2 = new ArrayList<Object>();
            for (Map.Entry<String, Object> entry2 : value.entrySet()) {
                list2.add(asDocument(key,
                        asDocument("$not", asDocument(entry2.getKey(), entry2.getValue()))));
            }
            return asDocument("$or", list2);
        }
    }
Serializes the given Querydsl query to a Document query for MongoDB.

@author Mark Paluch
querydsl-mongodb/src/main/java/com/querydsl/mongodb/document/MongodbDocumentSerializer.java