Merge.hs: build balanced dependency tree instead of skewed

Massively speeds up flattening that tree back.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>