Bug 319011 NPE when closing editor after closing a perspective
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java
newWindow.getChildren().add(uiRoot);
		if (curParent instanceof MPerspective) {
			MPerspective persp = (MPerspective) curParent;
			persp.getWindows().add(newWindow);
			MWindow window = getTopLevelWindowFor(persp);
			IPresentationEngine renderingEngine = persp.getContext().get(IPresentationEngine.class);
			Object foo = renderingEngine.createGui(newWindow, window.getWidget(),
					window.getContext());
			if (foo != null)
				System.out.println(foo.toString());
		} else if (curParent instanceof MWindow) {
			((MWindow) curParent).getWindows().add(newWindow);
		}
	}
	/**
	 * @param element
	 * @return
	 */
	private MWindowElement wrapElementForWindow(MPartSashContainerElement element) {
		if (element instanceof MWindowElement)
			return (MWindowElement) element;
		if (element instanceof MPlaceholder) {
			MUIElement ref = ((MPlaceholder) element).getRef();
			if (ref instanceof MPart) {
				MPartStack newPS = MBasicFactory.INSTANCE.createPartStack();
				newPS.getChildren().add((MPlaceholder) element);
				return newPS;
			}
		}
		return null;