Clustered random forests with correlated data for optimal estimation and inference under potential covariate shift