static List<TreeNode<K>> collapseAll<K>(List<TreeNode<K>> nodes) { return replaceNodes(nodes, (node) { return node.expanded ? node.updateState(expanded: false) : null; }); }