@NotNull
  static PsiPackage doMovePackage(@NotNull PsiPackage aPackage,
                                  @NotNull GlobalSearchScope scope,
                                  @NotNull MoveDestination moveDestination) throws IncorrectOperationException {
    final PackageWrapper targetPackage = moveDestination.getTargetPackage();

    final String newPrefix;
    if (targetPackage.getQualifiedName().isEmpty()) {
      newPrefix = "";
    }
    else {
      newPrefix = targetPackage.getQualifiedName() + ".";
    }

    final String newPackageQualifiedName = newPrefix + aPackage.getName();

    // do actual move
    PsiDirectory[] dirs = aPackage.getDirectories(scope);
    for (PsiDirectory dir : dirs) {
      final PsiDirectory targetDirectory = moveDestination.getTargetDirectory(dir);
      if (targetDirectory != null) {
        moveDirectoryRecursively(dir, targetDirectory);
      }
    }

    return new PsiPackageImpl(aPackage.getManager(), newPackageQualifiedName);
  }
@NotNull
  static PsiPackage doMovePackage(@NotNull PsiPackage aPackage,
                                  @NotNull GlobalSearchScope scope,
                                  @NotNull MoveDestination moveDestination)