@php $singleRootMode = count($tree) === 1 && count($tree[0]['children']) > 1; $rootNode = $singleRootMode ? $tree[0] : null; $splitNodes = $singleRootMode ? $rootNode['children'] : $tree; $third = (int) ceil(count($splitNodes) / 3); $treeColumns = [ array_slice($splitNodes, 0, $third), array_slice($splitNodes, $third, $third), array_slice($splitNodes, $third * 2), ]; @endphp @if($tree === [])