The implementation for simple codecs lives in yang-data-impl as TypeDefinitionAwareCodec. This is a misnomer, as this only handles simple codecs – not identity-ref, nor instance-identifier.
Reimplement the equivalent functionality as SimpleValueCodec in yang.data.util.codec, which will not be handling unions. It should also operate on yang.data.api.type.NormalizedType instead of on TypeDefinition.