How to get GameWorld in editor

I can use GWorld to get GameWorld in a game, but not sure how to get GameWorld in Editor. My code is not implemented in an Actor, so I can not just simply use GetWorld(). In Editor, the GWorld sometimes return GameWorld and sometimes return EditorWorld.

This will work in “Play In Editor” mode. Did not check other editor modes, but it has to be usable for them too.

    		if(GEditor)
    		{
    			return GEditor->PlayWorld;
    		}