Program: 166897
Project: 166897
Buggy source:
protected void handleHasSteps(ListIterator<Step<?,?>> iterator,int pathCount){
  int countToGoPrevious=0;
  while (iterator.hasNext()) {
    Step<?,?> currentStep=iterator.next();
    countToGoPrevious++;
    String notNullKey=null;
    String nullKey=null;
    if (currentStep instanceof HasContainerHolder) {
      HasContainerHolder hasContainerHolder=(HasContainerHolder)currentStep;
      List<HasContainer> hasContainers=hasContainerHolder.getHasContainers();
      List<HasContainer> toRemoveHasContainers=new ArrayList<>();
      toRemoveHasContainers.addAll(optimizeLabelHas(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeIdHas(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeHas(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeWithInOut(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeBetween(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeInside(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeOutside(this.currentReplacedStep,hasContainers));
      toRemoveHasContainers.addAll(optimizeTextContains(this.currentReplacedStep,hasContainers));
      if (toRemoveHasContainers.size() == hasContainers.size()) {
        if (!currentStep.getLabels().isEmpty()) {
          final IdentityStep identityStep=new IdentityStep<>(this.traversal);
          currentStep.getLabels().forEach(l -> this.currentReplacedStep.addLabel(pathCount + BaseStrategy.PATH_LABEL_SUFFIX + l));
          TraversalHelper.insertAfterStep(identityStep,currentStep,this.traversal);
        }
        if (this.traversal.getSteps().contains(currentStep)) {
          this.traversal.removeStep(currentStep);
        }
        iterator.remove();
        countToGoPrevious--;
      }
    }
 else     if ((notNullKey=isNotNullStep(currentStep)) != null) {
      this.currentReplacedStep.addHasContainer(new HasContainer(notNullKey,new P<String>(Existence.NOTNULL,null)));
      if (!currentStep.getLabels().isEmpty()) {
        final IdentityStep identityStep=new IdentityStep<>(this.traversal);
        currentStep.getLabels().forEach(l -> this.currentReplacedStep.addLabel(pathCount + BaseStrategy.PATH_LABEL_SUFFIX + l));
        TraversalHelper.insertAfterStep(identityStep,currentStep,this.traversal);
      }
      if (this.traversal.getSteps().contains(currentStep)) {
        this.traversal.removeStep(currentStep);
      }
      iterator.remove();
      countToGoPrevious--;
    }
 else     if ((nullKey=isNullStep(currentStep)) != null) {
      this.currentReplacedStep.addHasContainer(new HasContainer(nullKey,new P<String>(Existence.NULL,null)));
      if (!currentStep.getLabels().isEmpty()) {
        final IdentityStep identityStep=new IdentityStep<>(this.traversal);
        currentStep.getLabels().forEach(l -> this.currentReplacedStep.addLabel(pathCount + BaseStrategy.PATH_LABEL_SUFFIX + l));
        TraversalHelper.insertAfterStep(identityStep,currentStep,this.traversal);
      }
      if (this.traversal.getSteps().contains(currentStep)) {
        this.traversal.removeStep(currentStep);
      }
      iterator.remove();
      countToGoPrevious--;
    }
 else     if (currentStep instanceof IdentityStep) {
    }
 else {
      for (int i=0; i < countToGoPrevious; i++) {
        iterator.previous();
      }
      break;
    }
  }
}

Fixed version (ground truth):
protected void handleHasSteps(ListIterator<Step<?,?>> iterator,int pathCount){
  int countToGoPrevious=0;
  while (iterator.hasNext()) {
    Step<?,?> currentStep=iterator.next();
    countToGoPrevious++;
    String notNullKey=null;
    String nullKey=null;
    if (currentStep instanceof HasContainerHolder) {
      HasContainerHolder hasContainerHolder=(HasContainerHolder)currentStep;
      List<HasContainer> hasContainers=hasContainerHolder.getHasContainers();
      if (isNotWithMultipleColumnValue(hasContainerHolder)) {
        List<HasContainer> toRemoveHasContainers=new ArrayList<>();
        toRemoveHasContainers.addAll(optimizeLabelHas(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeIdHas(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeHas(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeWithInOut(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeBetween(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeInside(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeOutside(this.currentReplacedStep,hasContainers));
        toRemoveHasContainers.addAll(optimizeTextContains(this.currentReplacedStep,hasContainers));
        if (toRemoveHasContainers.size() == hasContainers.size()) {
          if (!currentStep.getLabels().isEmpty()) {
            final IdentityStep identityStep=new IdentityStep<>(this.traversal);
            currentStep.getLabels().forEach(l -> this.currentReplacedStep.addLabel(pathCount + BaseStrategy.PATH_LABEL_SUFFIX + l));
            TraversalHelper.insertAfterStep(identityStep,currentStep,this.traversal);
          }
          if (this.traversal.getSteps().contains(currentStep)) {
            this.traversal.removeStep(currentStep);
          }
          iterator.remove();
          countToGoPrevious--;
        }
      }
    }
 else     if ((notNullKey=isNotNullStep(currentStep)) != null) {
      this.currentReplacedStep.addHasContainer(new HasContainer(notNullKey,new P<String>(Existence.NOTNULL,null)));
      if (!currentStep.getLabels().isEmpty()) {
        final IdentityStep identityStep=new IdentityStep<>(this.traversal);
        currentStep.getLabels().forEach(l -> this.currentReplacedStep.addLabel(pathCount + BaseStrategy.PATH_LABEL_SUFFIX + l));
        TraversalHelper.insertAfterStep(identityStep,currentStep,this.traversal);
      }
      if (this.traversal.getSteps().contains(currentStep)) {
        this.traversal.removeStep(currentStep);
      }
      iterator.remove();
      countToGoPrevious--;
    }
 else     if ((nullKey=isNullStep(currentStep)) != null) {
      this.currentReplacedStep.addHasContainer(new HasContainer(nullKey,new P<String>(Existence.NULL,null)));
      if (!currentStep.getLabels().isEmpty()) {
        final IdentityStep identityStep=new IdentityStep<>(this.traversal);
        currentStep.getLabels().forEach(l -> this.currentReplacedStep.addLabel(pathCount + BaseStrategy.PATH_LABEL_SUFFIX + l));
        TraversalHelper.insertAfterStep(identityStep,currentStep,this.traversal);
      }
      if (this.traversal.getSteps().contains(currentStep)) {
        this.traversal.removeStep(currentStep);
      }
      iterator.remove();
      countToGoPrevious--;
    }
 else     if (currentStep instanceof IdentityStep) {
    }
 else {
      for (int i=0; i < countToGoPrevious; i++) {
        iterator.previous();
      }
      break;
    }
  }
}