function flattenTree(tree, transform, listedDirs) {
	const list = [];
	const { children } = tree;
	if (!children) {
		return [transform(tree)];
	}

	if (listedDirs.includes(tree.url)) return list;

	listedDirs.push(tree.url);

	children.forEach((item) => {
		if (item.children) list.push(...flattenTree(item, transform, listedDirs));
		else list.push(transform(item));
	});
	return list;
}
Get all files
@param {Tree} tree
@param {(item:Tree)=>object} transform