find common ancestors of refs