/**
  * Check the validity of the expression with regard to the data model
  * and the query in which it is used
  *
  * @param ModelReflection $oModelReflection MetaModel to consider
  * @param array $aClasses Flat list of classes
  * @return string the lowest common ancestor amongst classes, null if none has been found
  * @throws Exception
  */
 public static function GetLowestCommonAncestor(ModelReflection $oModelReflection, $aClasses)
 {
     $sAncestor = null;
     foreach ($aClasses as $sClass) {
         if (is_null($sAncestor)) {
             // first loop
             $sAncestor = $sClass;
         } elseif ($sClass == $sAncestor) {
             // remains the same
         } elseif ($oModelReflection->GetRootClass($sClass) != $oModelReflection->GetRootClass($sAncestor)) {
             $sAncestor = null;
             break;
         } else {
             $sAncestor = self::LowestCommonAncestor($oModelReflection, $sAncestor, $sClass);
         }
     }
     return $sAncestor;
 }