With the ExtensionData property we get access to the VirtualMachine object.
Most of the Managed vSphere objects has a property, called Parent, that points to the object to which our object is connected (the 'parent' in other words).
The contents of the Parent property is a MoRef (a pointer). To get at the actual object we use the Get-View cmdlet with this MoRef.
We repeat this process in a While loop till the parent object is a Datacenter object.
It's a bit like following the tree structure in the vSphere Client.
You start with the ESX(i) server and go up in the tree until you encounter a Datacenter.