laravel-nestedset
                                
                                 laravel-nestedset copied to clipboard
                                
                                    laravel-nestedset copied to clipboard
                            
                            
                            
                        [Need Review & Test] Can create tree with items from different levels
Phenomenon
With below data structure, if I use toTree, the items indexed with 2 will be eliminated from the result.
$categories = [
  0 => [ "id" => 10068, "parent_id" => 1, "name" => "A"],
  1 => [ "id" => 10085, "parent_id" => 10068, "name" => "B" ],
  2 => [ "id" => 10081, "parent_id" => null, "name" => "D" ]
]
Solution needs to be reviewed
The conditional statement modified to include the nodes (ROOT) has no parent.
/** @var Model|NodeTrait $node */
foreach ($this->items as $node) {
    if ($node->getParentId() == $root || ! $node->getParentId()) {
       $items[] = $node;
    }
}
linked #491
Please do not merge the PR, found some issue with duplicated items, I will fix and create a new patch.