class CaseManagementCommandUtil {

    @SuppressWarnings("unchecked")
    public static int getNewChildCanvasIndex(final Node<View<?>, Edge> parent) {
        Predicate<Node> predicate = Objects.isNull(parent.getContent())
                || !(parent.getContent().getDefinition() instanceof CaseManagementDiagram)
                ? CaseManagementCommandUtil::isSubStageNode : CaseManagementCommandUtil::isStageNode;

        return (int) parent.getOutEdges().stream()
                .filter(childPredicate())
                .filter(edge -> predicate.test(edge.getTargetNode())).count();
    }

}