class GraphBuilder {

    public void buildGraph(BpmnNode rootNode) {
        this.addNode(rootNode.value());
        rootNode.getEdges().forEach(this::addEdge);
        List<BpmnNode> nodes = rootNode.getChildren();

        Deque<BpmnNode> workingSet =
                new ArrayDeque<>(prioritized(nodes));

        Set<BpmnNode> workedOff = new HashSet<>();
        while (!workingSet.isEmpty()) {
            BpmnNode current = workingSet.pop();
            // ensure we visit this node only once
            if (workedOff.contains(current)) {
                continue;
            }
            workedOff.add(current);
            workingSet.addAll(
                    prioritized(current.getChildren()));

            this.addChildNode(current);
            current.getEdges().forEach(this::addEdge);
        }
    }

    public  GraphBuilder(
            Graph<DefinitionSet, Node> graph,
            DefinitionManager definitionManager,
            TypedFactoryManager typedFactoryManager,
            RuleManager ruleManager,
            GraphCommandFactory commandFactory,
            GraphCommandManager commandManager);

}