Show HN: JsonTree, a 3.53kb JavaScript tool for generating html trees from JSON
maxleiter.github.io
maxleiter.github.io
Consider using an actual class or a closure perhaps?
https://github.com/cheezmeister/kapok
[I think it does most of what yours does](https://github.com/Cheezmeister/kapok/blob/master/tst/kapok....) (EDIT: Nope, missing URL loading and XSS cleaning!)
Here's an example of a tree widget that can be navigated by keyboard: https://www.jstree.com/docs/html/
It's much better to rely on a toggle like input type=checkbox and CSS to visualize tree expand and collapse based on checkbox states than to install click handlers in javascript. I suspect you could make such an arrangement more accessible and keyboard navigable as well (via grouping.)
Javascript should only be used to dynamically load/unload subtrees on click in the case of especially huge or costly trees.