Revert "Merge remote-tracking branch 'upstream/production' into performance"

This reverts commit 017ed6910e14f0ab12f4338e142dbdc39723ef83, reversing
changes made to 0828f211034c41ddef60b83bd34f3a835b36e6de.
Reduce number of children() and count() calls.
Avoid expensive array_key_exists() calls.
Merge commit '630a803' into performance

Conflicts:
	pirum

Re-add the commits from upstream/improve-build-performance