function convertTree (rst) {
const result = []
// traverse the tree
rst.forEach((item) => { // destructuring assignment let { value: value, label: label, children: children } = item;
// If there are children, recurse
if (children) { children = convertTree(children); }
result.push({
value,
label,
children
})
})
return result;
}