Program: 62331
Project: 62331
Buggy source:
public void addPathToTree(Path path,final TreeItem<Item> treeItem){
  threadService.runTaskLater((() -> {
    if (Objects.isNull(path) || Objects.isNull(treeItem)) {
      return;
    }
    if (!Files.isDirectory(path)) {
      return;
    }
    if (!Files.exists(path)) {
      return;
    }
    if (treeItem == treeView.getRoot()) {
      pathItemMap.clear();
      directoryItemMap.clear();
      fileWatchService.reCreateWatchService();
    }
    directoryItemMap.put(path,treeItem);
    pathItemMap.put(path,treeItem);
    try (DirectoryStream<Path> directoryStream=Files.newDirectoryStream(path)){
      List<TreeItem<Item>> subItemList=StreamSupport.stream(directoryStream.spliterator(),false).sorted(pathOrder::comparePaths).map(p -> {
        TreeItem<Item> childItem=new PathItem(new Item(p),awesomeService.getIcon(p));
        if (Files.isDirectory(p)) {
          if (!IOHelper.isEmptyDir(p)) {
            childItem.getChildren().add(new PathItem(new Item(null,"String_Node_Str")));
          }
          childItem.setExpanded(false);
          childItem.expandedProperty().addListener((observable,oldValue,newValue) -> {
            if (newValue) {
              addPathToTree(childItem.getValue().getPath(),childItem);
            }
          }
);
        }
        pathItemMap.put(p,childItem);
        return childItem;
      }
).collect(Collectors.toList());
      threadService.runActionLater(() -> {
        saveTreeSelectionState();
        treeItem.getChildren().clear();
        treeView.getSelectionModel().clearSelection();
        treeItem.getChildren().addAll(subItemList);
        restoreTreeSelectionState();
        restoreTreeScrollState();
        treeView.requestFocus();
        fileWatchService.registerPathWatcher(path);
      }
);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str",e);
    }
  }
));
}

Fixed version (ground truth):
public void addPathToTree(Path path,final TreeItem<Item> treeItem){
  threadService.runTaskLater((() -> {
    if (Objects.isNull(path) || Objects.isNull(treeItem)) {
      return;
    }
    if (!Files.isDirectory(path)) {
      return;
    }
    if (!Files.exists(path)) {
      return;
    }
    if (treeItem == treeView.getRoot()) {
      pathItemMap.clear();
      directoryItemMap.clear();
      fileWatchService.reCreateWatchService();
    }
    directoryItemMap.put(path,treeItem);
    pathItemMap.put(path,treeItem);
    try (DirectoryStream<Path> directoryStream=Files.newDirectoryStream(path)){
      List<TreeItem<Item>> subItemList=StreamSupport.stream(directoryStream.spliterator(),false).sorted(pathOrder::comparePaths).map(p -> {
        TreeItem<Item> childItem=new PathItem(new Item(p),awesomeService.getIcon(p));
        if (Files.isDirectory(p)) {
          if (!IOHelper.isEmptyDir(p)) {
            childItem.getChildren().add(new PathItem(new Item(null,"String_Node_Str")));
          }
          childItem.setExpanded(false);
          childItem.expandedProperty().addListener((observable,oldValue,newValue) -> {
            if (newValue) {
              addPathToTree(childItem.getValue().getPath(),childItem);
            }
          }
);
        }
        pathItemMap.put(p,childItem);
        return childItem;
      }
).collect(Collectors.toList());
      threadService.runActionLater(() -> {
        saveTreeSelectionState();
        boolean treeViewFocused=treeView.isFocused();
        treeItem.getChildren().clear();
        treeView.getSelectionModel().clearSelection();
        treeItem.getChildren().addAll(subItemList);
        restoreTreeSelectionState();
        restoreTreeScrollState();
        if (treeViewFocused) {
          treeView.requestFocus();
        }
        fileWatchService.registerPathWatcher(path);
      }
);
    }
 catch (    Exception e) {
      logger.warn("String_Node_Str",e);
    }
  }
));
}