Program: 121977
Project: 121977
Buggy source:
@Override public void run(){
  TreeNode model=(TreeNode)nodePart.getModel();
  TreeNode docRoot=XmlMapUtil.getTreeNodeRoot(model);
  AbstractInOutTree abstractTree=(AbstractInOutTree)docRoot.eContainer();
  boolean isLookup=abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
  if (model instanceof OutputTreeNode) {
    OutputTreeNode outputNode=(OutputTreeNode)model;
    if (docRoot != null) {
      XmlMapUtil.cleanSubGroup(outputNode);
      List<TreeNode> newLoopUpGroups=new ArrayList<TreeNode>();
      findUpGroupNode(newLoopUpGroups,outputNode);
      XmlMapUtil.cleanSubGroup(docRoot,newLoopUpGroups);
      if (!newLoopUpGroups.isEmpty()) {
        TreeNode rootGroup=newLoopUpGroups.get(newLoopUpGroups.size() - 1);
        upsetGroup(outputNode,rootGroup);
      }
    }
  }
  if (!isLookup) {
    List<TreeNode> loopNodes=new ArrayList<TreeNode>();
    checkSubElementIsLoop(model,loopNodes);
    checkParentElementIsLoop(model,loopNodes);
    if (!loopNodes.isEmpty()) {
      if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
      }
 else {
        return;
      }
    }
    for (    TreeNode treeNode : loopNodes) {
      treeNode.setLoop(false);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(model);
    XmlMapUtil.upsetMainNode(model);
    abstractTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(abstractTree));
    if (input) {
      XmlMapUtil.removeloopInOutputTree(mapperManager,loopNodes);
    }
 else {
      for (      TreeNode treeNode : loopNodes) {
        InputLoopNodesTable inputLoopNodesTable=((OutputTreeNode)treeNode).getInputLoopNodesTable();
        if (inputLoopNodesTable != null && abstractTree != null) {
          ((OutputXmlTree)abstractTree).getInputLoopNodesTables().remove(inputLoopNodesTable);
          inputLoopNodesTable.getInputloopnodes().clear();
        }
        ((OutputTreeNode)treeNode).setInputLoopNodesTable(null);
      }
    }
  }
 else {
    if (docRoot != null) {
      cleanSubLoop(docRoot);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(docRoot);
    XmlMapUtil.upsetMainNode(model);
  }
  if (abstractTree != null) {
    mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
    mapperManager.getMapperUI().updateStatusBar();
  }
}

Fixed version (ground truth):
@Override public void run(){
  TreeNode model=(TreeNode)nodePart.getModel();
  TreeNode docRoot=XmlMapUtil.getTreeNodeRoot(model);
  AbstractInOutTree abstractTree=(AbstractInOutTree)docRoot.eContainer();
  boolean isLookup=abstractTree != mapperManager.getMainInputTree() && !(abstractTree instanceof OutputXmlTree);
  if (model instanceof OutputTreeNode) {
    OutputTreeNode outputNode=(OutputTreeNode)model;
    if (docRoot != null) {
      XmlMapUtil.cleanSubGroup(outputNode);
      List<TreeNode> newLoopUpGroups=new ArrayList<TreeNode>();
      findUpGroupNode(newLoopUpGroups,outputNode);
      XmlMapUtil.cleanSubGroup(docRoot,newLoopUpGroups);
      if (!newLoopUpGroups.isEmpty()) {
        TreeNode rootGroup=newLoopUpGroups.get(newLoopUpGroups.size() - 1);
        upsetGroup(outputNode,rootGroup);
      }
    }
  }
  if (!isLookup) {
    List<TreeNode> loopNodes=new ArrayList<TreeNode>();
    checkSubElementIsLoop(model,loopNodes);
    checkParentElementIsLoop(model,loopNodes);
    if (!loopNodes.isEmpty()) {
      if (MessageDialog.openConfirm(Display.getDefault().getActiveShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"))) {
      }
 else {
        return;
      }
    }
    for (    TreeNode treeNode : loopNodes) {
      treeNode.setLoop(false);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(model);
    XmlMapUtil.upsetMainNode(model);
    abstractTree.setMultiLoops(XmlMapUtil.checkMultiLoopsStatus(abstractTree));
    if (input) {
      XmlMapUtil.removeloopInOutputTree(mapperManager,loopNodes);
    }
 else {
      InputXmlTree mainInput=mapperManager.getMainInputTree();
      XmlMapUtil.removeLoopTableForOutput((OutputXmlTree)abstractTree,loopNodes,mainInput == null ? false : mainInput.isMultiLoops());
    }
  }
 else {
    if (docRoot != null) {
      cleanSubLoop(docRoot);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(docRoot);
    XmlMapUtil.upsetMainNode(model);
  }
  if (abstractTree != null) {
    mapperManager.getProblemsAnalyser().checkProblems(abstractTree);
    mapperManager.getMapperUI().updateStatusBar();
  }
}