I know it is an old post, but I'll drop here my findings after spending an hour in a similar problem.
The method "isPathValid" only validates if the sequence is correct by checking if the child (x) belongs to the parent (x - 1), but it doesn't validate if the root is the same as the table model (unless the path count is zero).
When filtering, you usually trigger a new root to the table model, so if you captured the TreePaths "before" updating the model (and triggering a new root), the table won't be able to find the path, although the path itself is valid.
It should work with a few of changes:
public **List** getPath(TreeNode node) {
List<TreeNode> list = new ArrayList<TreeNode>();
**while (node != model.getRoot()) {**
list.add(node);
node = node.getParent();
}
Collections.reverse(list);
**return list;**
}
**for (List elem : f.getTreePaths()) {**
elem.add(0, model.getRoot());
tree.expandPath(new TreePath(elem.toArray());
tree.scrollPathToVisible(elem);
}