function transform(root) {
if (root === null)
return null;
if(root.display_titles)
delete root['display_titles']
return Object.keys(root).map((k, index )=> {
const children = transform(root[k]);
return {
name: k,
index,
[children === null ? "value" : "children"] : children === null ? 1 : children
}
})
}