diff --git a/src/mapper/flattener.py b/src/mapper/flattener.py
index 41eaa40d0e50c7e8916e7a77b921a19677c7515c..ee05303f2ad00476be9c95e4c689795565e69621 100644
--- a/src/mapper/flattener.py
+++ b/src/mapper/flattener.py
@@ -6,11 +6,11 @@ from pymbolic.mapper import IdentityMapper
 class FlattenMapper(IdentityMapper):
     def map_sum(self, expr):
         from pymbolic.primitives import flattened_sum
-        return flattened_sum(expr.children)
+        return flattened_sum(self.rec(ch) for ch in expr.children)
 
     def map_product(self, expr):
         from pymbolic.primitives import flattened_product
-        return flattened_product(expr.children)
+        return flattened_product(self.rec(ch) for ch in expr.children)
 
     def handle_unsupported_expression(self, expr):
         return expr