I think we can reach this point for a directory when TreeWalk.isRecursive() is false and all of the trees are equal above.

When that happens we'll NPE below when isModified() tries to use a null DirCacheEntry.

We should either document in the class Javadoc that this filter must only be used on a recursive TreeWalk, or we should return true if FileMode.TREE.equals(wm), so the subtree can be considered by the caller.

A more aggressive (and much more complex) approach would be to recursively stat validate the directory contents if the DirCacheIterator has a valid ObjectId for this tree from the 'TREE' cache extension.  If all of the files are stat clean, we can return false back, preventing the need to dive into the tree objects from the repository.  That may save some CPU time, but its really frigging hard to get right here in the face of SkipWorkTreeFilter and NotIgnoredFilter also being in the same filter graph (or not being in the filter graph, depending on what the caller wants).