@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 testThrowsExceptionIfTooManyProxies() {
        assertThatThrownBy(
                        () ->
                                WrappingProxyUtil.stripProxy(
                                        new SelfWrappingProxy(
                                                WrappingProxyUtil.SAFETY_NET_MAX_ITERATIONS)))
                .isInstanceOf(IllegalArgumentException.class)
                .hasMessageContaining("Are there loops in the object graph?");
    }