There are a few ways to do this in PowerShell (on the SharePoint box).
All of the below examples will result with https://teams.SharePoint.com/sites/site
The best way is to call the Root Site Collection's Web:
$web = Get-SPWeb "https://teams.SharePoint.com/sites/site/communities/subsite"
$web.Site
You can try calling the Parent Web for each web (not as useful):
$web = Get-SPWeb "https://teams.SharePoint.com/sites/site/communities/subsite"
$web.ParentWeb.ParentWeb
or even try calling the Parent's Root Site Collection Web (same result as the first example - all webs will have the same common root site collection web):
$web = Get-SPWeb "https://teams.SharePoint.com/sites/site/communities/subsite"
$web.ParentWeb.Site
First example is the easiest. The other examples are just to show you the "ParentWeb" property.