Sadly, iterating twice won't work, as this will create directory
associations in the wrong direction, and there's no way mappings
let you iterate backwards. Let's mark the entries as directories
and then swap them out with the directories when building a zdir
tree instead.