PsiDirectory (PsiElement[] movedElements) { PsiDirectory commonDirectory = null; for (PsiElement movedElement : movedElements) { final PsiDirectory containingDirectory; if (movedElement instanceof PsiDirectory) { containingDirectory = ((PsiDirectory)movedElement).getParentDirectory(); } else { final PsiFile containingFile = movedElement.getContainingFile(); containingDirectory = containingFile == null ? null : containingFile.getContainingDirectory(); } if (containingDirectory != null) { if (commonDirectory == null) { commonDirectory = containingDirectory; } else { if (commonDirectory != containingDirectory) { return null; } } } } return commonDirectory; }