freshmaker-cli: Use "dep_on_id" to generate the tree, fix the prod/stage links.
To be able to change the rebuilt_nvr when build fails for unknown reason,
we need to stop relying on rebuilt_nvr in the freshmaker-cli and instead
use the dep_on_id.
This commit changes the code to construct the tree based on the images
dependencies to use the dep_on_id. It also documents the way how this
code works and rationalise it a bit.