Program: 144664
Project: 144664
Buggy source:
/** 
 * Rebuilding this node from an imported instance
 */
public void populate(TreeElement incoming){
  if (this.isLeaf()) {
    IAnswerData value=incoming.getValue();
    if (value == null) {
      this.setValue(null);
    }
 else {
      this.setValue(AnswerDataFactory.templateByDataType(this.dataType).cast(value.uncast()));
    }
  }
 else {
    for (int i=0; i < this.getNumChildren(); i++) {
      TreeElement child=this.getChildAt(i);
      if (child.getMaskVar(MASK_REPEATABLE) && child.getMult() != TreeReference.INDEX_TEMPLATE) {
        this.removeChildAt(i);
        i--;
      }
    }
    for (int i=0; i < this.getNumChildren(); i++) {
      TreeElement child=this.getChildAt(i);
      Vector newChildren=incoming.getChildrenWithName(child.getName());
      if (child.getMaskVar(MASK_REPEATABLE)) {
        for (int k=0; k < newChildren.size(); k++) {
          TreeElement newChild=child.deepCopy(true);
          newChild.setMult(k);
          if (children == null) {
            children=new Vector();
          }
          this.children.insertElementAt(newChild,i + k + 1);
          newChild.populate((TreeElement)newChildren.elementAt(k));
        }
        i+=newChildren.size();
      }
 else {
        if (newChildren.size() == 0) {
          child.setRelevant(false);
        }
 else {
          child.populate((TreeElement)newChildren.elementAt(0));
        }
      }
    }
  }
  for (int i=0; i < incoming.getAttributeCount(); i++) {
    String name=incoming.getAttributeName(i);
    String ns=incoming.getAttributeNamespace(i);
    String value=incoming.getAttributeValue(i);
    this.setAttribute(ns,name,value);
  }
}

Fixed version (ground truth):
/** 
 * Rebuilding this node from an imported instance
 */
public void populate(TreeElement incoming){
  if (this.isLeaf()) {
    IAnswerData value=incoming.getValue();
    if (value == null) {
      this.setValue(null);
    }
 else {
      this.setValue(AnswerDataFactory.templateByDataType(this.dataType).cast(value.uncast()));
    }
  }
 else {
    for (int i=0; i < this.getNumChildren(); i++) {
      TreeElement child=this.getChildAt(i);
      if (child.getMaskVar(MASK_REPEATABLE) && child.getMult() != TreeReference.INDEX_TEMPLATE) {
        this.removeChildAt(i);
        i--;
      }
    }
    for (int i=0; i < this.getNumChildren(); i++) {
      TreeElement child=this.getChildAt(i);
      Vector newChildren=incoming.getChildrenWithName(child.getName());
      if (child.getMaskVar(MASK_REPEATABLE)) {
        for (int k=0; k < newChildren.size(); k++) {
          TreeElement newChild=child.deepCopy(true);
          newChild.setMult(k);
          if (children == null) {
            children=new Vector<TreeElement>();
          }
          this.children.insertElementAt(newChild,i + k + 1);
          newChild.populate((TreeElement)newChildren.elementAt(k));
        }
        i+=newChildren.size();
      }
 else {
        if (newChildren.size() == 0) {
          child.setRelevant(false);
        }
 else {
          child.populate((TreeElement)newChildren.elementAt(0));
        }
      }
    }
  }
  for (int i=0; i < incoming.getAttributeCount(); i++) {
    String name=incoming.getAttributeName(i);
    String ns=incoming.getAttributeNamespace(i);
    String value=incoming.getAttributeValue(i);
    this.setAttribute(ns,name,value);
  }
}