Fix error 121 when clicking on command line below another window

I get this when having NERDTree active and clicking on the command line below another window:
Error detected while processing function nerdtree#invokeKeyMap..69..111..nerdtree#getPath:
line   41:
E121: Undefined variable: b:NERDTreeRoot
E15: Invalid expression: b:NERDTreeRoot.path.str({'format': 'UI'}) . dir

I've only tried it in Cygwin on Windows 7.

There's surely a better solution for this but it works for me, for now.