Fix cache usage in TreeWalker in presence of filters.

TreeWalker should be able to somehow understand that even if there are messages, then the file may still be OK since there may be some filters blocking the messages.