can we add something like this: 

```
public static void maybeAdd(XContentBuilder builder, String key, Object value, Object defValue, boolean includeDefault) throws IOException {
        if (value != null || value != defValue) {
            builder.field(key, value);
        } else if (includeDefault) {
            builder.field(key, defValue);
        }
    }
```

I think this would make things much simpler here!