unpack-trees: reduce malloc in cache-tree walk