factor out common code in BeforeAfterNode and ChallengeNode into QuantitiesNode