presto-main/src/main/java/io/prestosql/sql/planner/iterative/Memo.java/Memo/insertChildrenAndRewrite
class Memo:    private PlanNode insertChildrenAndRewrite(PlanNode node)
    {
        return node.replaceChildren(
                node.getSources().stream()
                        .map(child -> new GroupReference(
                                idAllocator.getNextId(),
                                insertRecursive(child),
                                child.getOutputSymbols()))
                        .collect(Collectors.toList()));
    }