class PipelineNodeUtil {

    public static @CheckForNull String getCauseOfBlockage(@Nonnull FlowNode stage, @Nullable FlowNode nodeBlock) {
        if(nodeBlock != null){
            //Check and see if this node block is inside this stage
            for(FlowNode p:nodeBlock.getParents()){
                if(p.equals(stage)){
                    Queue.Item item = QueueItemAction.getQueueItem(nodeBlock);
                    if (item != null) {
                        CauseOfBlockage causeOfBlockage = item.getCauseOfBlockage();
                        String cause = null;
                        if (causeOfBlockage != null) {
                            cause = causeOfBlockage.getShortDescription();
                            if (cause == null) {
                                causeOfBlockage = item.task.getCauseOfBlockage();
                                if(causeOfBlockage != null) {
                                    return causeOfBlockage.getShortDescription();
                                }
                            }
                        }
                        return cause;
                    }
                }
            }
        }
        return null;
    }

}