Using Data Heterogeneity For Causal Effect Estimation And Robust Prediction