Iterated direct sums and products of modules