presto-main/src/main/java/io/prestosql/sql/planner/optimizations/PlanNodeSearcher.java/PlanNodeSearcher/findSingle
class PlanNodeSearcher:    public <T extends PlanNode> Optional<T> findSingle()
    {
        List<T> all = findAll();
        switch (all.size()) {
            case 0:
                return Optional.empty();
            case 1:
                return Optional.of(all.get(0));
            default:
                throw new IllegalStateException("Multiple nodes found");
        }
    }