boolean (final PsiElement[] elements, final PsiElement targetContainer, @Nullable PsiReference reference) { HashSet<String> names = new HashSet<>(); for (PsiElement element : elements) { if (element instanceof PsiFile file) { String name = file.getName(); if (names.contains(name)) { return false; } names.add(name); } else if (!(element instanceof PsiDirectory)) { return false; } } return super.canMove(elements, targetContainer, reference); }