Program: 121967
Project: 121967
Buggy source:
@Override public void run(){
  try {
    TreeNode docRoot=null;
    Object s=getSelectedObjects().get(0);
    if (s instanceof List && !((List)s).isEmpty()) {
      List selectedarts=new ArrayList((List)s);
      Iterator iter=selectedarts.iterator();
      while (iter.hasNext()) {
        Object obj=iter.next();
        if (obj instanceof TreeNodeEditPart) {
          TreeNodeEditPart nodePart=(TreeNodeEditPart)obj;
          TreeNode treeNode=(TreeNode)nodePart.getModel();
          if (treeNode.eContainer() instanceof TreeNode) {
            TreeNode parent=(TreeNode)treeNode.eContainer();
            if (docRoot == null) {
              docRoot=XmlMapUtil.getTreeNodeRoot(parent);
            }
            XmlMapUtil.detachNodeConnections(treeNode,mapperManager.getCopyOfMapData(),true);
            if (treeNode.isLoop()) {
              if (treeNode instanceof OutputTreeNode && XmlMapUtil.findUpGroupNode((OutputTreeNode)treeNode) != null) {
                XmlMapUtil.cleanSubGroup(docRoot);
              }
              XmlMapUtil.clearMainNode(docRoot);
            }
            parent.getChildren().remove(treeNode);
            List<TreeNode> loopNodes=new ArrayList<TreeNode>();
            if (docRoot != null && docRoot.eContainer() instanceof AbstractInOutTree) {
              AbstractInOutTree tree=(AbstractInOutTree)docRoot.eContainer();
              if (tree.isMultiLoops()) {
                List<TreeNode> nodesToCheck=new ArrayList<TreeNode>();
                nodesToCheck.add(docRoot);
                XmlMapUtil.getChildLoops(loopNodes,nodesToCheck,false);
                if (loopNodes.size() < 2) {
                  tree.setMultiLoops(false);
                }
              }
            }
            if (input) {
              List<TreeNode> subNodes=new ArrayList<TreeNode>();
              checkSubElementIsLoop(treeNode,subNodes);
              removeloopInOutputTree(subNodes);
            }
          }
        }
      }
    }
    if (mapperManager != null) {
      if (input) {
        if (docRoot != null && docRoot.eContainer() instanceof InputXmlTree) {
          mapperManager.refreshInputTreeSchemaEditor((InputXmlTree)docRoot.eContainer());
        }
      }
 else {
        if (docRoot != null && docRoot.eContainer() instanceof OutputXmlTree) {
          mapperManager.refreshOutputTreeSchemaEditor((OutputXmlTree)docRoot.eContainer());
        }
      }
      if (docRoot != null && docRoot.eContainer() instanceof AbstractInOutTree) {
        mapperManager.getProblemsAnalyser().checkProblems((AbstractInOutTree)docRoot.eContainer());
        mapperManager.getMapperUI().updateStatusBar();
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    TreeNode docRoot=null;
    Object s=getSelectedObjects().get(0);
    if (s instanceof List && !((List)s).isEmpty()) {
      List selectedarts=new ArrayList((List)s);
      Iterator iter=selectedarts.iterator();
      while (iter.hasNext()) {
        Object obj=iter.next();
        if (obj instanceof TreeNodeEditPart) {
          TreeNodeEditPart nodePart=(TreeNodeEditPart)obj;
          TreeNode treeNode=(TreeNode)nodePart.getModel();
          if (treeNode.eContainer() instanceof TreeNode) {
            TreeNode parent=(TreeNode)treeNode.eContainer();
            if (docRoot == null) {
              docRoot=XmlMapUtil.getTreeNodeRoot(parent);
            }
            XmlMapUtil.detachNodeConnections(treeNode,mapperManager.getCopyOfMapData(),true);
            if (treeNode.isLoop()) {
              if (treeNode instanceof OutputTreeNode && XmlMapUtil.findUpGroupNode((OutputTreeNode)treeNode) != null) {
                XmlMapUtil.cleanSubGroup(docRoot);
              }
              XmlMapUtil.clearMainNode(docRoot);
            }
            parent.getChildren().remove(treeNode);
            List<TreeNode> loopNodes=new ArrayList<TreeNode>();
            if (docRoot != null && docRoot.eContainer() instanceof AbstractInOutTree) {
              AbstractInOutTree tree=(AbstractInOutTree)docRoot.eContainer();
              if (tree.isMultiLoops()) {
                List<TreeNode> nodesToCheck=new ArrayList<TreeNode>();
                nodesToCheck.add(docRoot);
                XmlMapUtil.getChildLoops(loopNodes,nodesToCheck,false);
                if (loopNodes.size() < 2) {
                  tree.setMultiLoops(false);
                }
              }
            }
            if (input) {
              List<TreeNode> subNodes=new ArrayList<TreeNode>();
              checkSubElementIsLoop(treeNode,subNodes);
              XmlMapUtil.removeloopInOutputTree(mapperManager,subNodes);
            }
          }
        }
      }
    }
    if (mapperManager != null) {
      if (input) {
        if (docRoot != null && docRoot.eContainer() instanceof InputXmlTree) {
          mapperManager.refreshInputTreeSchemaEditor((InputXmlTree)docRoot.eContainer());
        }
      }
 else {
        if (docRoot != null && docRoot.eContainer() instanceof OutputXmlTree) {
          mapperManager.refreshOutputTreeSchemaEditor((OutputXmlTree)docRoot.eContainer());
        }
      }
      if (docRoot != null && docRoot.eContainer() instanceof AbstractInOutTree) {
        mapperManager.getProblemsAnalyser().checkProblems((AbstractInOutTree)docRoot.eContainer());
        mapperManager.getMapperUI().updateStatusBar();
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}