Program: 123780
Project: 123780
Buggy source:
@Override public void run(){
  TreeNodeEditPart nodePart=(TreeNodeEditPart)getSelectedObjects().get(0);
  TreeNode model=(TreeNode)nodePart.getModel();
  AbstractInOutTree abstractTree=null;
  TreeNode docRoot=null;
  if (model instanceof OutputTreeNode) {
    OutputTreeNode outputNode=(OutputTreeNode)model;
    docRoot=(OutputTreeNode)XmlMapUtil.getTreeNodeRoot(outputNode);
    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 (docRoot.eContainer() instanceof AbstractInOutTree) {
        abstractTree=(AbstractInOutTree)docRoot.eContainer();
      }
    }
  }
 else   if (model instanceof TreeNode) {
    docRoot=XmlMapUtil.getTreeNodeRoot(model);
    if (docRoot.eContainer() instanceof AbstractInOutTree) {
      abstractTree=(AbstractInOutTree)docRoot.eContainer();
    }
  }
  boolean hasDocument=false;
  if (abstractTree != null) {
    hasDocument=XmlMapUtil.hasDocument(abstractTree);
  }
  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);
  }
  if (input) {
    removeloopInOutputTree(loopNodes);
    addInputLoopNodesToOutput(model,model);
  }
  if (!input) {
    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);
    }
    List<TreeNode> sourceLoopNodes=new ArrayList<TreeNode>();
    findChildSourceLoop(model,sourceLoopNodes);
    if (!sourceLoopNodes.isEmpty()) {
      InputLoopNodesTable createInputLoopNodesTable=XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
      createInputLoopNodesTable.eAdapters().add(nodePart);
      ((OutputTreeNode)model).setInputLoopNodesTable(createInputLoopNodesTable);
      createInputLoopNodesTable.getInputloopnodes().addAll(sourceLoopNodes);
      ((OutputXmlTree)abstractTree).getInputLoopNodesTables().add(createInputLoopNodesTable);
    }
  }
  model.setLoop(true);
  XmlMapUtil.clearMainNode(model);
  XmlMapUtil.upsetMainNode(model);
  if (hasDocument) {
    loopNodeList.clear();
    getLoopNode(docRoot);
    if (loopNodeList != null && loopNodeList.size() > 1) {
      abstractTree.setMultiLoops(true);
    }
 else {
      abstractTree.setMultiLoops(false);
    }
  }
  if (abstractTree != null) {
    mapperManager.getProblemsAnalyser().checkLoopProblems(abstractTree);
    mapperManager.getMapperUI().updateStatusBar();
  }
}

Fixed version (ground truth):
@Override public void run(){
  TreeNodeEditPart nodePart=(TreeNodeEditPart)getSelectedObjects().get(0);
  TreeNode model=(TreeNode)nodePart.getModel();
  AbstractInOutTree abstractTree=null;
  TreeNode docRoot=null;
  if (model instanceof OutputTreeNode) {
    OutputTreeNode outputNode=(OutputTreeNode)model;
    docRoot=(OutputTreeNode)XmlMapUtil.getTreeNodeRoot(outputNode);
    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 (docRoot.eContainer() instanceof AbstractInOutTree) {
        abstractTree=(AbstractInOutTree)docRoot.eContainer();
      }
    }
  }
 else   if (model instanceof TreeNode) {
    docRoot=XmlMapUtil.getTreeNodeRoot(model);
    if (docRoot.eContainer() instanceof AbstractInOutTree) {
      abstractTree=(AbstractInOutTree)docRoot.eContainer();
      if (abstractTree != null && abstractTree instanceof InputXmlTree) {
        isLookup=((InputXmlTree)abstractTree).isLookup();
      }
    }
  }
  if (!isLookup) {
    boolean hasDocument=false;
    if (abstractTree != null) {
      hasDocument=XmlMapUtil.hasDocument(abstractTree);
    }
    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);
    }
    if (input) {
      removeloopInOutputTree(loopNodes);
      addInputLoopNodesToOutput(model,model);
    }
    if (!input) {
      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);
      }
      List<TreeNode> sourceLoopNodes=new ArrayList<TreeNode>();
      findChildSourceLoop(model,sourceLoopNodes);
      if (!sourceLoopNodes.isEmpty()) {
        InputLoopNodesTable createInputLoopNodesTable=XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
        createInputLoopNodesTable.eAdapters().add(nodePart);
        ((OutputTreeNode)model).setInputLoopNodesTable(createInputLoopNodesTable);
        createInputLoopNodesTable.getInputloopnodes().addAll(sourceLoopNodes);
        ((OutputXmlTree)abstractTree).getInputLoopNodesTables().add(createInputLoopNodesTable);
      }
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(model);
    XmlMapUtil.upsetMainNode(model);
    if (hasDocument) {
      loopNodeList.clear();
      getLoopNode(docRoot);
      if (loopNodeList != null && loopNodeList.size() > 1) {
        abstractTree.setMultiLoops(true);
      }
 else {
        abstractTree.setMultiLoops(false);
      }
    }
  }
 else {
    if (docRoot != null) {
      cleanSubLoop(docRoot);
    }
    model.setLoop(true);
    XmlMapUtil.clearMainNode(docRoot);
    XmlMapUtil.upsetMainNode(model);
  }
  if (abstractTree != null) {
    mapperManager.getProblemsAnalyser().checkLoopProblems(abstractTree);
    mapperManager.getMapperUI().updateStatusBar();
  }
}