Program: 32556
Project: 32556
Buggy source:
/** 
 * Handle a source insert at the specified index by adding the corresponding real node, or converting a virtual node to a real node. The real node is inserted, marked as real and hidden, and returned.
 * @param sourceIndex the index of the element in the source list that hasbeen inserted
 * @return the new node, prior to any events fired
 */
private Node<E> findOrInsertNode(int sourceIndex){
  Node<E> inserted=source.get(sourceIndex);
  inserted.reset();
  int predecessorIndex=sourceIndex > 0 ? data.convertIndexColor(sourceIndex - 1,REAL_NODES,ALL_NODES) : -1;
  int followerIndex=data.size(REAL_NODES) > sourceIndex ? data.convertIndexColor(sourceIndex,REAL_NODES,ALL_NODES) : data.size(ALL_NODES);
  int indexOfNearestAncestorByValue=predecessorIndex;
  int lengthOfLongestAncestorCommonPath;
  if (predecessorIndex >= 0) {
    Node<E> predecessor=data.get(predecessorIndex,ALL_NODES).get();
    lengthOfLongestAncestorCommonPath=commonPathLength(inserted,predecessor);
  }
 else {
    lengthOfLongestAncestorCommonPath=0;
  }
  for (int i=predecessorIndex + 1; i < followerIndex; i++) {
    Node<E> possibleAncestor=data.get(i,ALL_NODES).get();
    assert(possibleAncestor.virtual);
    if (possibleAncestor.pathLength() > inserted.pathLength())     continue;
    int commonPathLength=commonPathLength(inserted,possibleAncestor);
    if (commonPathLength == inserted.pathLength()) {
      replaceNode(possibleAncestor,inserted,false);
      return inserted;
    }
 else     if (commonPathLength > lengthOfLongestAncestorCommonPath) {
      lengthOfLongestAncestorCommonPath=commonPathLength;
      indexOfNearestAncestorByValue=i;
    }
  }
  addNode(inserted,HIDDEN_REAL,expansionModel,indexOfNearestAncestorByValue + 1);
  return inserted;
}

Fixed version (ground truth):
/** 
 * Handle a source insert at the specified index by adding the corresponding real node, or converting a virtual node to a real node. The real node is inserted, marked as real and hidden, and returned.
 * @param sourceIndex the index of the element in the source list that hasbeen inserted
 * @return the new node, prior to any events fired
 */
private Node<E> findOrInsertNode(int sourceIndex){
  Node<E> inserted=source.get(sourceIndex);
  inserted.resetDerivedState();
  int predecessorIndex=sourceIndex > 0 ? data.convertIndexColor(sourceIndex - 1,REAL_NODES,ALL_NODES) : -1;
  int followerIndex=data.size(REAL_NODES) > sourceIndex ? data.convertIndexColor(sourceIndex,REAL_NODES,ALL_NODES) : data.size(ALL_NODES);
  int indexOfNearestAncestorByValue=predecessorIndex;
  int lengthOfLongestAncestorCommonPath;
  if (predecessorIndex >= 0) {
    Node<E> predecessor=data.get(predecessorIndex,ALL_NODES).get();
    lengthOfLongestAncestorCommonPath=commonPathLength(inserted,predecessor);
  }
 else {
    lengthOfLongestAncestorCommonPath=0;
  }
  for (int i=predecessorIndex + 1; i < followerIndex; i++) {
    Node<E> possibleAncestor=data.get(i,ALL_NODES).get();
    assert(possibleAncestor.virtual);
    if (possibleAncestor.pathLength() > inserted.pathLength())     continue;
    int commonPathLength=commonPathLength(inserted,possibleAncestor);
    if (commonPathLength == inserted.pathLength()) {
      replaceNode(possibleAncestor,inserted,false);
      return inserted;
    }
 else     if (commonPathLength > lengthOfLongestAncestorCommonPath) {
      lengthOfLongestAncestorCommonPath=commonPathLength;
      indexOfNearestAncestorByValue=i;
    }
  }
  addNode(inserted,HIDDEN_REAL,indexOfNearestAncestorByValue + 1);
  return inserted;
}