unpack-trees: factor out dup_entry