I have a unique file structure representation which includes parents and children in a tree-like format
interface FileTreeProps {
name: string;
isMat?: boolean;
children?: FileTreeProps[];
}
Following user input and query submission, I am looking to filter the tree so that only nodes with the type isMat
at the endpoints are displayed. The initial parent folders will never have isMat = true
. Any suggestions on how to approach this filtering task?
To aid in this process, I already possess the script for comparing two strings for similarity and would like to only include those children where the similarity exceeds 0.25;
An example of a standard file layout (nodes denoted by paint brushes represent the isMat nodes): https://i.sstatic.net/Why29.png and sample object:
{
"name": "SubtlePBR",
"children": [
{
"name": "assets",
"children": [
{
"name": "minecraft",
"children": [
{
"name": "textures",
"children": [
{
"name": "block",
"children": [
{
"name": "acacia_leaves",
"children": [],
"isMat": true
},
{
"name": "acacia_log",
"children": [],
"isMat": true
}
]
}
]
}
]
}
]
}
]
}