getEntries() rabbit hole

Hi i been going crazy for the last 3 days trying to find out how to folder.getEntries() in deeply nested subfolders.

lets take for example:
getEntries

i select my root foder using fs.getFolder() using the GUI selector…
then inside my selected root folder, i have DISPLAY folder, version_X_XXXX folders (where x can be anything), then in each JPGs folder and finally jpg files.

i can go as far lisitng JPGs Folder but i cant get the entries for the JPGs folder… (i.e. i cannot retrieve the jpg files in jpgs folder) i get nothing… is there a limit in how deep i can go?

async function GetJpgEntries() {
    console.log("should work");
    let displayFolders = (await reviewFolder.getEntries()).find(entry => entry.name.includes('DISPLAY'));
    let displayContents = (await displayFolders.getEntries());
    displayContents = (await displayContents.filter(entry => entry.isFolder));
    let versionFolders = (await displayContents.map(entry => entry.getEntries()));


    for await (let versionFolder of versionFolders) {
        versionFolder = (await versionFolder.filter(entry => entry.name.includes('JPGs')));
        console.log(versionFolder.toString());
    }
}

i can see my paths but im stuck on further descending down on getting entries for JPGs folder

Off the top of my head, but I think this should work.

const fs = require("uxp").storage.localFileSystem;

async function getAllJpegEntries(rootFolder) {
    const allTheJpegs = []; // collector array

    // `getEntry` can get a specific path without having to use .filter()
    const theDisplayFolder = await rootFolder.getEntry("DISPLAY");

    // here, get all the folders that start with version_
    const theVersionFolders = (await theDisplayFolder.getEntries())
        .filter(entry => entry.isFolder && entry.name.startsWith("version_"));

    
    // next, loop over al the version folders in sequence
    for await (const aVersionFolder of theVersionFolders) {
        // get the JPGs folder within
        const jpegsFolder = await aVersionFolder.getEntry("JPGs");

        // and get all the entries within that are files ending with .jpg.
        const allTheJpegsInFolder = (await jpegsFolder.getEntries())
            .filter(entry => entry.isFile && entry.name.endsWith(".jpg"));

        // add them to our collector array
        allTheJpegs.push(...allTheJpegsInFolder);        
    }
    return allTheJpegs;
}