```
var files = [];
for (const entry of Object.entries(collection)) {
    var folder = "";
    entry.forEach(item => {
        if (typeof item == "string") {
            folder = item;
        }

        if (typeof item == "object") {
            item.forEach(file => {
                files.push(folder + "/" + file); // append files only (recursive)      
            })
        }

    });
    // sometimes lists contain names of children directories. check with the top parent to exclude directory names
    files = files.filter(x => !Object.keys(collection).includes(x));
}
console.log(files);

```

There is a javascript object `collection` which is a collection of key-value pairs representing some directory.  

Each key is the name of a subdirectory and its value is of type list, particularly a list of filenames only that are inside that directory.

This code works and it gets a list of absolute filepath names from the base directory recursively through some additional logic and concatenation.

I'm having a hard time rewriting this code to purely use .map(), .filter(), .find(), .pipe() or curry methods

Feedback appreciated