code: public static BsonDocument copyOfDocument(final BsonDocument document) {
      final BsonDocument newDocument = new BsonDocument();
      for (final Map.Entry<String, BsonValue> kv : document.entrySet()) {
        newDocument.put(kv.getKey(), kv.getValue());
      }
      return newDocument;
    }
docs: Returns a copy of the given document.
  @param document the document to copy.
  @return a copy of the given document.