def METHOD_NAME(segarr, zscore=1.96):
    """Merge segments by Standard Error of the Mean (SEM).
    Use each segment's SEM value to estimate a 95% confidence interval (via
    `zscore`). Segments with lower CI above 0 are kept as gains, upper CI below
    0 as losses, and the rest with CI overlapping zero are collapsed as neutral.
    """
    margin = segarr["sem"] * zscore
    levels = np.zeros(len(segarr))
    levels[segarr["log2"] - margin > 0] = 1
    levels[segarr["log2"] + margin < 0] = -1
    return squash_by_groups(segarr, pd.Series(levels))