proper check for existence of a window object

I believe there's a mistake, since `if (window) ...` check is useless (always true in browsers, will throw in node.js).

PS: what about lazy-loading of esprima? I don't particularly like how 100kb library is loaded every time even when I don't use full schema.