private static PsiClass copy(PsiClass aClass, String name) {
   final PsiClass classNavigationElement = (PsiClass) aClass.getNavigationElement();
   final PsiClass classCopy = (PsiClass) classNavigationElement.copy();
   if (name != null) {
     classCopy.setName(name);
   }
   return classCopy;
 }