let locations = {}
function format(arr) {
arr.forEach(x => {
if(x.children && x.children.length > 0) {
let item = {}
for ( let i=0;i<x.children.length;i++){
item[x.children[i].value] = x.children[i].label
locations[x.value] = item
format(x.children)
}
} else {
return
}
})
}
format(result)
console.log(locations)