protected function determineDepth($node, $nesting = 0) { // Traverse back up the ancestry chain and add to the nesting level count while ($parent = $node->parent()->first()) { $nesting++; $node = $parent; } return [$node, $nesting]; }