Creating a treeview of google drive folders

I want to create a JSON database of folders (only) from google drive for a tree view pane,
I have tried to extract the database using google sheets using this code

var level=0;
getFnF()

function getFnF(folder) {
  var folder= folder || DriveApp.getFolderById(" ID HERE");
  var sh=SpreadsheetApp.getActiveSheet();
  var subfolders=folder.getFolders() 
  while(subfolders.hasNext()) {
    var subfolder=subfolders.next();
    var forg=sh.getRange(sh.getLastRow() + 1,level + 1);
    forg.setValue(Utilities.formatString(subfolder.getName() + "      "+ subfolder.getId()));
    level++;
    getFnF(subfolder);
  }
  level--;
}

but i stuck on how transforming it to a database such this formate :

export const treeMenu = [
  {
    key: "Folder id",
    label: "folder1",
    nodes: [
      {
        key: "Folder id",
        label: "sub-folder",
        nodes: [
          {
            key: "Folder id",
            label: "sub-sub-folder",
            nodes: [],
          },
        ],
      },
    ],
  },
  {
    key: "Folder id",
    label: "folder",
  },
];