protected void encodeThis(ByteBuffer buffer) {
        byte CODE_MASK =     0b00011111;
        byte FEAT_WEIGHT =   0b00100000;
        byte FEAT_UNIQUEID = 0b01000000;
        byte FEAT_FLAGS =   -0b10000000;

        int code = getCode();
        byte type = code >= CODE_MASK ? CODE_MASK : (byte) code;
        if (code >= 0x80 + CODE_MASK)
            throw new IllegalStateException("must increase number of bytes in serialization format for queries");

        if (weight != DEFAULT_WEIGHT) {
            type |= FEAT_WEIGHT;
        }
        if (hasUniqueID()) {
            type |= FEAT_UNIQUEID;
        }
        byte flags = getFlagsFeature();
        if (flags != 0) {
            type |= FEAT_FLAGS;
        }

        buffer.put(type);
        if (code >= CODE_MASK) {
            // This is an extension to the serialization to work around original 5 bits limit for code
            buffer.put((byte) (code - CODE_MASK));
        }
        if ((type & FEAT_WEIGHT) != 0) {
            IntegerCompressor.putCompressedNumber(weight, buffer);
        }
        if ((type & FEAT_UNIQUEID) != 0) {
            IntegerCompressor.putCompressedPositiveNumber(uniqueID, buffer);
        }
        if ((type & FEAT_FLAGS) != 0) {
            buffer.put(flags);
        }
    }
Returns the parent in the query tree, or null if this node has no parent
container-search/src/main/java/com/yahoo/prelude/query/Item.java