perf: optimize internal isWindow call

Each window has a reference to itself, which is pretty unique so we can use
that to simplify our isWindow check