How to get the current keyboard icon ?

Does anybody know how to obtain the icon of the currently selected keyboard?
As of right now, keyboard icons are stored in two different places:
1. /System/Library/Keyboard Layouts/Unicode.bundle/Contents/Resources inside "icns" files
2. /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/HIToolbox.rsrc inside "kcns" resources
To get the current keyboard layout:
OSStatus osErr;
KeyboardLayoutRef keyRef;

osErr = KLGetCurrentKeyboardLayout( &keyRef );

Once you have a keyboard reference, you can get get the icon reference:

IconRef icon;
osErr = KLGetKeyboardLayoutProperty( keyRef, kKLIcon, (void*)(&icon) );

And finally convert it to an NSImage:

IconFamilyHandle fam;
NSData* imgData;
NSImage* img;

osErr = IconRefToIconFamily( icon, kSelectorAllAvailableData, &fam );
imgData = [NSData dataWithBytes:*fam length:GetHandleSize((Handle)fam)];
img = [[NSImage alloc] initWithData:imgData];