SWindow::GetTopmostAncestor

Look up the parent chain until we find the top-level window that owns this window