I need to get the latest parent in a nested tree with laravel :
Example:

Schema of the table in my database :

Relationships in my model :
public function parentUnit() {
return $this->belongsTo('Unit', 'unit_id', 'id');
}
public function allParentUnit() {
return $this->parentUnit()->with('allParentUnit');
}
Question:
How can I get the latest parent in the picture above:
The latest parent of G is A
And the last parent of F is B