private void removeNotAccepted(@NotNull N node, Set<U> accepted) {
      IntList removedIds = new IntArrayList();
      List<N> removedNodes = new ArrayList<>();
      for (int i = node.getChildCount() - 1; i >= 0; --i) {
        N child = getChild(node, i);
        if (!accepted.contains(getUserObject(child))) {
          removedIds.add(i);
          removedNodes.add(child);
          node.remove(i);
        }
      }
      if (!removedIds.isEmpty()) {
        Collections.reverse(removedNodes);
        int[] ints = removedIds.toIntArray();
        for (int i = 0; i < ints.length / 2; i++) {
          int temp = ints[i];
          ints[i] = ints[ints.length - i - 1];
          ints[ints.length - i - 1] = temp;
        }
        nodesWereRemoved(node, ints, removedNodes.toArray());
      }
    }
private void removeNotAccepted(@NotNull N node, Set<U> accepted)