tail recursive helper without sanity checks
function makePow(left, prev) {
  if (left.isEmpty()) {
    return prev;
  }
  const elem = left.first();
  return makePow(
    left.remove(elem),
    prev.union(prev.map(e => e.add(elem)))
  );
}