Bug 1906: Fixed bug in Binding leafref to union codec

In models, where leafref was used to reference type, incorrect
codec (EncapsulatedValueCodec) was used for all cases with
derived type instead of actual codec. EncapsulatedValueCodec
covered most cases except Union and Bits.

Added special handling for leafref, where type definition
for referenced leaf is fetched and codec is used based
on that notion.

Change-Id: Id790554e1e84bcf01179add4f5327a4e7380ebe1
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
(cherry picked from commit 697925b94246e725412b88151ec097c812a65b39)
Signed-off-by: Robert Varga <rovarga@cisco.com>