+
+ // retain orphaned references in grandparent categories
+ for (let id in selection) {
+ selection[id][3] = function subresolve(subs) {
+ //console.log(subs);
+ return (subs || []).flatMap(sub =>
+ sub in selection ? [sub] : subresolve(json[sub][3])
+ );
+ }(selection[id][3]);
+ }
+ return selection;