class CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand {

    @SuppressWarnings("unchecked")
    void removeExistingRelationship(final GraphCommandExecutionContext context) {
        originalParent.ifPresent(p -> {
            if (isStage(p, child)) {
                originalIn = child.getInEdges().stream()
                        .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getSourceNode()).findAny();
                originalOut = child.getOutEdges().stream()
                        .filter(sequencePredicate()).map(e -> (Node<View<?>, Edge>) e.getTargetNode()).findAny();
            }
        });

        // Remove existing relationship
        getEdgeForTarget(originalParent, child, childPredicate())
                .ifPresent((e) -> removeRelationship(e,
                                                     originalParent.get(),
                                                     child,
                                                     context));
        getEdgeForTarget(originalIn, child, sequencePredicate())
                .ifPresent((e) -> removeRelationship(e,
                                                     originalIn.get(),
                                                     child,
                                                     context));
        getEdgeForSource(originalOut, child, sequencePredicate())
                .ifPresent((e) -> removeRelationship(e,
                                                     child,
                                                     originalOut.get(),
                                                     context));

        // Connect the two nodes linked to the moved node
        if (originalIn.isPresent() && originalOut.isPresent()) {
            addRelationship(originalIn.get(),
                            originalOut.get(),
                            OptionalInt.empty(),
                            context,
                            sequenceFlowSupplier());
        }
    }

    public  CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent,
                                                  final Node<View<?>, Edge> child,
                                                  final OptionalInt index,
                                                  final Optional<Node<View<?>, Edge>> originalParent,
                                                  final OptionalInt originalIndex);

}