Please use this signature:

void CollectFiles (HashSet<FilePath> files, List<FilePath> directories, FilePath dir, bool recursive)

It took me a while to realize that the "versions" parameter actually doesn't have anything to do with versions