@Override
  public void checkAdd(@NotNull PsiElement element) throws IncorrectOperationException {
    CheckUtil.checkWritable(this);
    if (element instanceof PsiDirectory || element instanceof PsiFile) {
      String name = ((PsiFileSystemItem)element).getName();
      boolean caseSensitive = getVirtualFile().isCaseSensitive();
      VirtualFile existing = ContainerUtil.find(getVirtualFile().getChildren(),
                                                item -> Comparing.strEqual(item.getName(), name, caseSensitive));
      if (existing != null) {
        throw new IncorrectOperationException(
          CoreBundle.message(existing.isDirectory() ? "dir.already.exists.error" : "file.already.exists.error",
                             existing.getPresentableUrl()));
      }
    }
    else {
      throw new IncorrectOperationException(element.getClass().getName());
    }
  }
@Override
  public void checkAdd(@NotNull PsiElement element)