def _prune_body(self, res, transforms=None):
        """Return a masked version of *res* where pruned rows/cols are masked.

        Return value is an `np.ma.MaskedArray` object. Pruning is the removal
        of rows or columns whose corresponding marginal elements are either
        0 or not defined (np.nan).
        """
        if self.ndim > 2:
            return self._prune_3d_body(res, transforms)

        res = self._drop_mr_cat_dims(res)

        # ---determine which rows should be pruned---
        row_margin = self._pruning_base(
            hs_dims=transforms, axis=self.row_direction_axis
        )
        # ---adjust special-case row-margin values---
        item_types = (DT.MR, DT.CA_SUBVAR)
        if self.ndim > 1 and self.dim_types[1] in item_types and len(res.shape) > 1:
            # ---when row-dimension has only one category it gets squashed---
            axis = 1 if res.shape[0] > 1 else None
            # ---in CAT x MR case (or if it has CA subvars) we get
            # a 2D margin (denom really)---
            row_margin = np.sum(row_margin, axis=axis)
        row_prune_inds = self._margin_pruned_indices(
            row_margin, self._inserted_dim_inds(transforms, 0), 0
        )

        # ---a 1D only has rows, so mask only with row-prune-idxs---
        if self.ndim == 1 or len(res.shape) == 1:
            # For 1D, margin is calculated as the row margin.
            return np.ma.masked_array(res, mask=row_prune_inds)

        # ---determine which columns should be pruned---
        col_margin = self._pruning_base(
            hs_dims=transforms, axis=self._col_direction_axis
        )
        if col_margin.ndim > 1:
            # In case of MR x CAT, we have 2D margin
            col_margin = np.sum(col_margin, axis=0)
        col_prune_inds = self._margin_pruned_indices(
            col_margin, self._inserted_dim_inds(transforms, 1), 1
        )

        # ---create rows x cols mask and mask the result array---
        mask = self._create_mask(res, row_prune_inds, col_prune_inds)
        res = np.ma.masked_array(res, mask=mask)

        # ---return the masked array---
        return res