It feels to me that it would be a lot more simpler to just do:

```js
if (win instanceof Ci.nsIDOMWindow) return PrivateBrowsingUtils.isWindowPrivate(win);
try { return !!win.docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing; }
catch (_) { return false }
```