private static void relax(Counter<UnaryRule> pathCosts,
			Map<UnaryRule, String> intermediateStates,
			Map<String, List<UnaryRule>> closedUnaryRulesByChild,
			Map<String, List<UnaryRule>> closedUnaryRulesByParent,
			UnaryRule unaryRule, String intermediateState, double newScore) {
		if (intermediateState != null
				&& (intermediateState.equals(unaryRule.getParent()) || intermediateState
						.equals(unaryRule.getChild())))
			return;
		boolean isNewRule = !pathCosts.containsKey(unaryRule);
		double oldScore = (isNewRule ? Double.NEGATIVE_INFINITY : pathCosts
				.getCount(unaryRule));
		if (oldScore > newScore)
			return;
		if (isNewRule) {
			CollectionUtils.addToValueList(closedUnaryRulesByChild,
					unaryRule.getChild(), unaryRule);
			CollectionUtils.addToValueList(closedUnaryRulesByParent,
					unaryRule.getParent(), unaryRule);
		}
		pathCosts.setCount(unaryRule, newScore);
		intermediateStates.put(unaryRule, intermediateState);
	}