The problem benind the question sounds like Limbic~Region's coworker is trying to write yet another package manager, e. g. for Linux distributions. The source code of e. g. apt (Debian, in C++) or portage (Gentoo, in Python) might provide further insight.
Beeing lazy in programming, I'd try creative use of 'make': After transferring the dependencies into a Makefile, 'make -t' creates the dependeny tree in an empty directory as 0 byte files. After 'touch'ing the file to be removed, 'make -n' provides a suitable action plan that just needs reversing.