Issue #2642374 by alexpott, Berdir, drunken monkey, beejeebus: Dependency removal logic incorrectly affects indirect dependents