In discovery phase, there was logic to not process packages
multiple times. However, that logic failed to account the package's
depth and install_if state for the name being processed. This
caused install_if processing failure in certain topologies of the
dependency graph. Adds also a test case that should catch this
issue reliably.
* each package name has two sorting positions, one which causes
install_if triggers to be run, and other for bulk dependencies
* fix also inverted ordering of package installations