@SuppressWarnings("unchecked")
    public static <T> T stripProxy(@Nullable final WrappingProxy<T> wrappingProxy) {
        if (wrappingProxy == null) {
            return null;
        }

        T delegate = wrappingProxy.getWrappedDelegate();

        int numProxiesStripped = 0;
        while (delegate instanceof WrappingProxy) {
            throwIfSafetyNetExceeded(++numProxiesStripped);
            delegate = ((WrappingProxy<T>) delegate).getWrappedDelegate();
        }

        return delegate;
    }
@Test
    void testStripsAllProxies() {
        final SelfWrappingProxy wrappingProxy =
                new SelfWrappingProxy(WrappingProxyUtil.SAFETY_NET_MAX_ITERATIONS - 1);
        assertThat(WrappingProxyUtil.stripProxy(wrappingProxy))
                .isNotInstanceOf(SelfWrappingProxy.class);
    }