archive: make use of the index to recursively read the tree

Instead of recursing ourselves, read the tree into an index, where we
simply need a loop to insert the entries into the tarball.