public static EObject findCommonAncestor(List<EObject> o1Anchestors,List<EObject> o2Anchestors){
  int max=Math.min(o1Anchestors.size(),o2Anchestors.size());
  EObject commonAncestor=null;
  for (int i=0; i < max; i++) {
    if (o1Anchestors.get(i) == o2Anchestors.get(i)) {
      commonAncestor=o1Anchestors.get(i);
    }
 else {
      break;
    }
  }
  return commonAncestor;
}

public static EObject findCommonAncestor ( List < EObject > o1Anchestors , List < EObject > o2Anchestors ) { int max = Math . min ( o1Anchestors . size ( ) , o2Anchestors . size ( ) ) ; EObject commonAncestor = null ; for ( int i = 0 ; i < max ; i ++ ) { if ( o1Anchestors . get ( i ) == o2Anchestors . get ( i ) ) { commonAncestor = o1Anchestors . get ( i ) ; } else { break ; } } return commonAncestor ; }
calculates the common ancestor of to eobjects based on two ancestor list . the lists are compareredstarting from the root . the last same element is the common ancestor .
