presto-main/src/main/java/io/prestosql/cost/CachingCostProvider.java/CachingCostProvider/getGroupCost
class CachingCostProvider:    private PlanCostEstimate getGroupCost(GroupReference groupReference)
    {
        int group = groupReference.getGroupId();
        Memo memo = this.memo.orElseThrow(() -> new IllegalStateException("CachingCostProvider without memo cannot handle GroupReferences"));

        Optional<PlanCostEstimate> knownCost = memo.getCost(group);
        if (knownCost.isPresent()) {
            return knownCost.get();
        }

        PlanCostEstimate cost = calculateCost(memo.getNode(group));
        verify(!memo.getCost(group).isPresent(), "Group cost already set");
        memo.storeCost(group, cost);
        return cost;
    }