TestProxyRoot (@NotNull AbstractTestProxy proxy) { if (proxy instanceof TestProxyRoot) { return (TestProxyRoot)proxy; } AbstractTestProxy parent = proxy.getParent(); while (parent != null && !(parent instanceof TestProxyRoot)) { parent = parent.getParent(); } return parent != null ? (TestProxyRoot)parent : null; }