0👍
I believe this is what you are looking for. I have written comments in the code to explain my thought process.
showFiles(id) {
for (const dataObject of this.data) {
if (this.dataObject.children && this.dataObject.children.id === id) { // check if file has children and if the child id is the same as the id. If it is, the files are the files of the nested child
this.files = this.dataObject.children.files;
break;
}
if (!this.dataObject.children && this.dataObject.id === id) { // if the data object does not have children and the id is the same as the id being looked for, the file is the root folder
this.files = this.dataObject.files;
break;
}
}
}
Source:stackexchange.com