Flattening expression trees