Program: 100754
Project: 100754
Buggy source:
private void moveMeta(final Entry<String,Element> entry,final Element root){
  final List<String> metaPath=moveTable.get(entry.getKey());
  if (metaPath == null) {
    return;
  }
  final Iterator<String> token=metaPath.iterator();
  Node parent=null;
  Node child=root;
  Node current=null;
  Node item=null;
  NodeList childElements;
  boolean createChild=false;
  while (token.hasNext()) {
    final String next=token.next();
    parent=child;
    final Integer nextIndex=compareTable.get(next);
    Integer currentIndex=null;
    childElements=parent.getChildNodes();
    for (int i=0; i < childElements.getLength(); i++) {
      String name=null;
      String classValue=null;
      current=childElements.item(i);
      if (current.getNodeType() == Node.ELEMENT_NODE) {
        name=current.getNodeName();
        classValue=((Element)current).getAttribute(ATTRIBUTE_NAME_CLASS);
      }
      if ((name != null && current.getNodeName().equals(next)) || (classValue != null && (classValue.contains(next)))) {
        child=current;
        break;
      }
 else       if (name != null) {
        currentIndex=compareTable.get(name);
        if (currentIndex == null) {
          String generalizedName=classValue.substring(classValue.indexOf(SLASH) + 1);
          generalizedName=generalizedName.substring(0,generalizedName.indexOf(STRING_BLANK));
          currentIndex=compareTable.get(generalizedName);
        }
        if (currentIndex == null) {
          logger.error(MessageUtils.getInstance().getMessage("String_Node_Str",name).toString());
          break;
        }
        if (currentIndex.compareTo(nextIndex) > 0) {
          break;
        }
      }
    }
    if (child == parent) {
      child=parent.getOwnerDocument().createElement(next);
      final DitaClass cls=new DitaClass("String_Node_Str" + next + "String_Node_Str");
      ((Element)child).setAttribute(ATTRIBUTE_NAME_CLASS,cls.toString());
      if (current == null || currentIndex == null || nextIndex.compareTo(currentIndex) >= 0) {
        parent.appendChild(child);
        current=null;
      }
 else {
        parent.insertBefore(child,current);
        current=null;
      }
      createChild=true;
    }
  }
  final NodeList list=entry.getValue().getChildNodes();
  for (int i=0; i < list.getLength(); i++) {
    item=list.item(i);
    if ((i == 0 && createChild) || MapMetaReader.uniqueSet.contains(entry.getKey())) {
      item=parent.getOwnerDocument().importNode(item,true);
      parent.replaceChild(item,child);
      child=item;
    }
 else {
      item=parent.getOwnerDocument().importNode(item,true);
      ((Element)parent).insertBefore(item,child);
    }
  }
}

Fixed version (ground truth):
private void moveMeta(final Entry<String,Element> entry,final Element root){
  final List<String> metaPath=moveTable.get(entry.getKey());
  if (metaPath == null) {
    return;
  }
  final Iterator<String> token=metaPath.iterator();
  Node parent=null;
  Node child=root;
  Node current=null;
  Node item=null;
  NodeList childElements;
  boolean createChild=false;
  while (token.hasNext()) {
    final String next=token.next();
    parent=child;
    final Integer nextIndex=compareTable.get(next);
    Integer currentIndex=null;
    childElements=parent.getChildNodes();
    for (int i=0; i < childElements.getLength(); i++) {
      String name=null;
      String classValue=null;
      current=childElements.item(i);
      if (current.getNodeType() == Node.ELEMENT_NODE) {
        name=current.getNodeName();
        classValue=((Element)current).getAttribute(ATTRIBUTE_NAME_CLASS);
      }
      if ((name != null && current.getNodeName().equals(next)) || (classValue != null && (classValue.contains(next)))) {
        child=current;
        break;
      }
 else       if (name != null) {
        currentIndex=compareTable.get(name);
        if (currentIndex == null) {
          String generalizedName=classValue.substring(classValue.indexOf(SLASH) + 1);
          generalizedName=generalizedName.substring(0,generalizedName.indexOf(STRING_BLANK));
          currentIndex=compareTable.get(generalizedName);
        }
        if (currentIndex == null) {
          logger.error(MessageUtils.getInstance().getMessage("String_Node_Str",name).toString());
          break;
        }
        if (currentIndex.compareTo(nextIndex) > 0) {
          break;
        }
      }
    }
    if (child == parent) {
      child=parent.getOwnerDocument().createElement(next);
      final DitaClass cls=new DitaClass("String_Node_Str" + next + "String_Node_Str");
      ((Element)child).setAttribute(ATTRIBUTE_NAME_CLASS,cls.toString());
      if (current == null || currentIndex == null || nextIndex.compareTo(currentIndex) >= 0) {
        parent.appendChild(child);
        current=null;
      }
 else {
        parent.insertBefore(child,current);
        current=null;
      }
      createChild=true;
    }
  }
  final NodeList list=entry.getValue().getChildNodes();
  for (int i=0; i < list.getLength(); i++) {
    item=list.item(i);
    if ((i == 0 && createChild) || MapMetaReader.uniqueSet.contains(entry.getKey())) {
      item=parent.getOwnerDocument().importNode(item,true);
      parent.replaceChild(item,child);
      child=item;
    }
 else {
      item=parent.getOwnerDocument().importNode(item,true);
      parent.insertBefore(item,child);
    }
  }
}