class CaseManagementCommandUtil {

    public static boolean isStageNode(final Node<View<?>, Edge> node) {
        if (node.getContent().getDefinition() instanceof AdHocSubprocess) {
            final List<Node> childNodes = node.getOutEdges().stream()
                    .filter(childPredicate())
                    .map(Edge::getTargetNode).collect(Collectors.toList());

            return childNodes.isEmpty()
                    || childNodes.stream().allMatch(CaseManagementCommandUtil::isSubStageNode);
        }

        return false;
    }

}