More elegant method of preventing redundant recursion

When expanding subsets of sums and prods