utility to combine two dimensions of a multi-dimensional array