/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-6a365ba
 * Released under the MIT license.
 */

export function toFlatTree(tree, includingFolders) {
    return tree.reduce((result, node) => {
        if (!node.isLeaf) {
            result = [
                ...result,
                ...(includingFolders ? [node] : []),
                ...toFlatTree(node.children || [], includingFolders),
            ];
        }
        else {
            result.push(node);
        }
        return result;
    }, []);
}

        