code: function reformat(object) {
    if (typeof object !== 'object') return object;
  
    var entries = [];
    var entry;
  
    for (var key in object) {
      entry = reformat(object[key]);
      if (typeof entry === 'string') {
        entry.label = key;
        entries.push(entry);
      } else {
        entry = { nodes: entry, label: key };
        entries.push(entry);
      }
    }
  
    return entries;
  }
docs: inspired from https://github.com/hughsk/file-tree