Problem with a node.js recursive function (with pupeeter) – var not defined

I made a program with pupeteer that retrieves the list of button ids and their names.

I want to loop through these buttons then click on them and retrieve the ids and names…

So I created a recursive function which, with a list as input, allows you to browse and click.

Here is my code:

  return Array.isArray(a) &&
    Array.isArray(b) &&
    a.length === b.length &&
    a.every((val, index) => val === b[index]);
}

async function parcourt(liste, previousListe, path, page) {
                    console.log(liste)

 for (const bouton of liste) {
    if(!arrayEquals(liste, previousListe)){
        const id = await page.evaluate(el => el.id, bouton);
        const titres = await bouton.$$('div[class^="Cell_title"]')
        const titre = await page.evaluate(el => el.innerText, titres[0]);
        var Newpath = path + "/" + titre
        console.log(Newpath + " : " + id)
        await bouton.click()
        var Newliste = await page.$$('div[id^="catalog-"]')
        parcourt(await NewListe,liste,await Newpath,page)
    }
    return 0
 }
}



const getData = async () => {
  // 1 - Créer une instance de navigateur
  const browser = await puppeteer.launch({ headless: false })
  const page = await browser.newPage()

  // 2 - Naviguer jusqu'à l'URL cible
await page.goto("xxxxxxx")
const liste = await page.$$('div[id^="catalog-"]')
parcourt(liste, [], '',page)

}

// Appel de la fonction getData() et affichage des données
getData().then(value => {
  console.log(value)
})