src/Database/NestedSet/Builder.php
protected static function fixNodes(array &$dictionary)
    {
        $fixed = 0;

        $cut = self::reorderNodes($dictionary, $fixed);

        // Save nodes that have invalid parent as roots
        while (!empty($dictionary)) {
            $dictionary[null] = reset($dictionary);

            unset($dictionary[key($dictionary)]);

            $cut = self::reorderNodes($dictionary, $fixed, null, $cut);
        }

        return $fixed;
    }
protected static function fixNodes(array &$dictionary)
    {
        $fixed = 0;

        $cut = self::reorderNodes($dictionary, $fixed);

        // Save nodes that have invalid parent as roots
        while (!empty($dictionary)) {
            $dictionary[null] = reset($dictionary);

            unset($dictionary[key($dictionary)]);

            $cut = self::reorderNodes($dictionary, $fixed, null, $cut);
        }

        return $fixed;
    }
@param array $dictionary

@return int