public static CompilationUnit getCompilationUnit(
     final SourceFile sourceFile, final CodeModel internalCodeModel) {
   for (AbstractCodeElement c : internalCodeModel.getCodeElement()) {
     if (c instanceof CompilationUnit) {
       for (SourceRef ref : c.getSource()) {
         for (SourceRegion r : ref.getRegion()) {
           if (r.getFile() == sourceFile) {
             return (CompilationUnit) c;
           }
         }
       }
     }
   }
   throw new IllegalStateException();
 }