boolean (final Project project, final PsiPackage srcPackage, final PsiElement targetElement, boolean showError) { final PsiPackage targetPackage = targetElement instanceof PsiPackage ? (PsiPackage)targetElement : targetElement instanceof PsiDirectory ? JavaDirectoryService.getInstance() .getPackage((PsiDirectory)targetElement) : null; for (PsiPackage curPackage = targetPackage; curPackage != null; curPackage = curPackage.getParentPackage()) { if (curPackage.equals(srcPackage)) { if (showError) { CommonRefactoringUtil.showErrorMessage(RefactoringBundle.message("move.title"), JavaRefactoringBundle.message("cannot.move.package.into.itself"), HelpID.getMoveHelpID(srcPackage), project); } return false; } } return true; }