public boolean isOnMainMergeBranch() {
   // return true even if got no branch.
   Map<INode, Integer> mapMerge = NodeUtil.getLinkedMergeInfo(this);
   if (mapMerge == null) {
     return true;
   } else {
     for (Integer i : mapMerge.values()) {
       if (i != 1) {
         return false;
       }
     }
     return true;
   }
 }
  /**
   * Will return the first item of the subprocess. If "withCondition" is true, if there is links
   * from type RunIf / RunAfter / RunBefore, it will return the first element found. If
   * "withCondition" is false, it will return the first element with no active link from type
   * Main/Ref/Iterate.<br>
   * <i><b>Note:</b></i> This function doesn't work if the node has several start points (will
   * return a random start node).
   *
   * @param withCondition
   * @return Start Node found.
   */
  public INode getSubProcessStartNode(boolean withConditions) {
    if (!withConditions) {
      Map<INode, Integer> mapMerge = NodeUtil.getLinkedMergeInfo(this);
      if (mapMerge == null) { // no merge after, so must be sub process start.
        if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) {
          return this;
        }
      } else {
        for (Integer i : mapMerge.values()) {
          if (i != 1) {
            // not first merge, so will take the last merge from the tree, and retrieve the main sub
            // process start.
            return mapMerge.keySet().iterator().next().getSubProcessStartNode(withConditions);
          }
        }
        if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) {
          return this; // main branch here, so we got the correct sub process start.
        }
      }
    } else {
      int nb = 0;
      for (IConnection connection : getIncomingConnections()) {
        if (connection.isActivate()) {
          nb++;
        }
      }
      if (nb == 0) {
        return this;
      }
    }
    IConnection connec;

    for (int j = 0; j < getIncomingConnections().size(); j++) {
      connec = getIncomingConnections().get(j);
      if (((AbstractNode) connec.getSource()).isOnMainMergeBranch()) {
        if (!connec.getLineStyle().equals(EConnectionType.FLOW_REF)) {
          return connec.getSource().getSubProcessStartNode(withConditions);
        }
      }
    }
    return null;
  }