def METHOD_NAME(value):
    if isinstance(value, (int, datatypes.Integer)):
        if isinstance(value, int):
            value = datatypes.Integer(value)
        v = value.get()
        return \
            ZeroOp() if v == 0 else \
            OneOp() if v == 1 else \
            ByteConst(v) if v <= 0xff else \
            WordConst(v) if v <= 0xffff else \
            DWordConst(v) if v <= 0xffffffff else \
            QWordConst(v)
    elif isinstance(value, datatypes.Buffer):
        buffer_size = len(value.get())
        builder = ByteConst if buffer_size <= 0xff else \
                  WordConst if buffer_size <= 0xffff else \
                  DWordConst if buffer_size <= 0xffffffff else \
                  QWordConst
        return DefBuffer(
            PkgLength(),
            builder(buffer_size),
            ByteList(value.get()))
    elif isinstance(value, datatypes.Package):
        elements = list(map(METHOD_NAME, value.elements))
        return DefPackage(
            PkgLength(),
            len(value.elements),
            PackageElementList(*elements))
    elif isinstance(value, (str, datatypes.String)):
        if isinstance(value, str):
            return String(value)
        else:
            return String(value.get())
    elif isinstance(value, datatypes.BufferField):
        return METHOD_NAME(value.to_integer())
    else:
        return None