$vhd = Get-ChildItem -Filter base* | Get-VHD 

$curdisk = "e:\export\virtual hard disks\base-w2019en.vhdx"; 
function Get-ParentAVHDX {
  param ($p); 
  $pp = $vhd | ?{$_.parentpath -eq $p}; 
  if ($pp) {
    Get-ParentAVHDX($pp.path); 
    write-host $pp.path $pp.parentpath; 
    Merge-VHD -Path $pp.Path -DestinationPath $pp.ParentPath -Verbose -WhatIf
  }
} 
Get-ParentAVHDX($curdisk)