protected static Serializer serializeOptional(Serializer buf, Identifiable obj) {
        if (obj != null) {
            buf.putByte(null, (byte)1);
            obj.serializeWithId(buf);
        } else {
            buf.putByte(null, (byte)0);
        }
        return buf;
    }
This is a convenience method to allow serialization of an optional field. A single byte is added to the buffer
indicating whether or not an object follows. If the object is not null, it is serialized following this flag.

@param buf The buffer to serialize to.
@param obj The object to serialize, may be null.
@return The buffer, to allow chaining.
vespajlib/src/main/java/com/yahoo/vespa/objects/Identifiable.java