SP-1320 - Backport of MONDRIAN-1061 - java.lang.StackOverflowError resulting from recursive calculated member usage within virtual cube (5.1)

back-port against 3.7
see https://github.com/pentaho/mondrian/pull/351