[SP-1338] - Backport of MONDRIAN-2107 - Incorrect segment rollup with overlapping segments (4.8)

cherry-pick 58005870ceab0249c91c33b19e0ddaaf9329586a and part of 29000ebd46be96b75e91724d80659459fca3659f