def _insertions(self, result, dimension, dimension_index):
        """Return list of (idx, sum) pairs representing subtotals.

        *idx* is the int offset at which to insert the ndarray subtotal
        in *sum*.
        """

        def iter_insertions():
            for anchor_idx, addend_idxs in dimension.hs_indices:
                insertion_idx = (
                    -1
                    if anchor_idx == "top"
                    else result.shape[dimension_index] - 1
                    if anchor_idx == "bottom"
                    else anchor_idx
                )
                addend_fancy_idx = tuple(
                    [slice(None) for _ in range(dimension_index)]
                    + [np.array(addend_idxs)]
                )
                yield (
                    insertion_idx,
                    np.sum(result[addend_fancy_idx], axis=dimension_index),
                )

        return [insertion for insertion in iter_insertions()]