Protection from empty/invalid root or kid in NameTree
Adds unicode conversion for js code
Merge pull request #2968 from yurydelendik/nametree

Misc NameTree/JavaScript fixes