Perform breadth-first traversal in collect_things_recur.

This should make results more accurate when the traversal limit is reached.
Also use a mapping to track visited things, to improve performance.
Bugfix in CacheTagEntry.cache_count_memory.

Collected objects are now provided individually to Pike.count_memory, rather
than just counting the result array (which defeats the purpose of collecting
all those objects to begin with).