Program: 142368
Project: 142368
Buggy source:
private void startNextFetch() throws SessionUnavailableException {
  CommCareSession session=CommCareApplication._().getCurrentSession();
  String needed=session.getNeededData();
  String[] lastPopped=session.getPoppedStep();
  if (needed == null) {
    startFormEntry(CommCareApplication._().getCurrentSessionWrapper());
  }
 else   if (needed == CommCareSession.STATE_COMMAND_ID) {
    Intent i=new Intent(getApplicationContext(),MenuList.class);
    i.putExtra(CommCareSession.STATE_COMMAND_ID,session.getCommand());
    startActivityForResult(i,GET_COMMAND);
  }
 else   if (needed == CommCareSession.STATE_DATUM_VAL) {
    Intent i=new Intent(getApplicationContext(),EntitySelectActivity.class);
    i.putExtra(CommCareSession.STATE_COMMAND_ID,session.getCommand());
    if (lastPopped != null && CommCareSession.STATE_DATUM_VAL.equals(lastPopped[0])) {
      i.putExtra(EntitySelectActivity.EXTRA_ENTITY_KEY,lastPopped[1]);
    }
    startActivityForResult(i,GET_CASE);
  }
 else   if (needed == CommCareSession.STATE_DATUM_COMPUTED) {
    SessionDatum datum=session.getNeededDatum();
    XPathExpression form;
    try {
      form=XPathParseTool.parseXPath(datum.getValue());
    }
 catch (    XPathSyntaxException e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage());
    }
    EvaluationContext ec=session.getEvaluationContext(new CommCareInstanceInitializer(session));
    if (datum.getType() == SessionDatum.DATUM_TYPE_FORM) {
      session.setXmlns(XPathFuncExpr.toString(form.eval(ec)));
      session.setDatum("String_Node_Str","String_Node_Str");
    }
 else {
      session.setDatum(datum.getDataId(),XPathFuncExpr.toString(form.eval(ec)));
    }
    startNextFetch();
    return;
  }
}

Fixed version (ground truth):
private void startNextFetch() throws SessionUnavailableException {
  CommCareSession session=CommCareApplication._().getCurrentSession();
  String needed=session.getNeededData();
  String[] lastPopped=session.getPoppedStep();
  if (needed == null) {
    startFormEntry(CommCareApplication._().getCurrentSessionWrapper());
  }
 else   if (needed == CommCareSession.STATE_COMMAND_ID) {
    Intent i=new Intent(getApplicationContext(),MenuList.class);
    i.putExtra(CommCareSession.STATE_COMMAND_ID,session.getCommand());
    startActivityForResult(i,GET_COMMAND);
  }
 else   if (needed == CommCareSession.STATE_DATUM_VAL) {
    Intent i=new Intent(getApplicationContext(),EntitySelectActivity.class);
    i.putExtra(CommCareSession.STATE_COMMAND_ID,session.getCommand());
    if (lastPopped != null && CommCareSession.STATE_DATUM_VAL.equals(lastPopped[0])) {
      i.putExtra(EntitySelectActivity.EXTRA_ENTITY_KEY,lastPopped[2]);
    }
    startActivityForResult(i,GET_CASE);
  }
 else   if (needed == CommCareSession.STATE_DATUM_COMPUTED) {
    SessionDatum datum=session.getNeededDatum();
    XPathExpression form;
    try {
      form=XPathParseTool.parseXPath(datum.getValue());
    }
 catch (    XPathSyntaxException e) {
      e.printStackTrace();
      throw new RuntimeException(e.getMessage());
    }
    EvaluationContext ec=session.getEvaluationContext(new CommCareInstanceInitializer(session));
    if (datum.getType() == SessionDatum.DATUM_TYPE_FORM) {
      session.setXmlns(XPathFuncExpr.toString(form.eval(ec)));
      session.setDatum("String_Node_Str","String_Node_Str");
    }
 else {
      session.setDatum(datum.getDataId(),XPathFuncExpr.toString(form.eval(ec)));
    }
    startNextFetch();
    return;
  }
}