public List<StepLog> createStackTrace(List<StepLog> stepLogList, String startIndex) {
    StepLog lastStep = null;
    StepLog prevLastStep = null;
    int maxLocalPathSize = 0;

    // find the last step
    for (StepLog stepLog : stepLogList) {
      String path = stepLog.getStepInfo().getPath();
      if (path.matches("^" + startIndex + ".\\d*")) {
        String[] splitPath = path.split("\\.");
        int currentLocalPath = Integer.parseInt(splitPath[splitPath.length - 1]);
        if (currentLocalPath >= maxLocalPathSize) {
          maxLocalPathSize = currentLocalPath;
          prevLastStep = lastStep;
          lastStep = stepLog;
        }
      }
    }

    List<StepLog> stackTrace;
    if (lastStep != null) {
      stackTrace =
          createStackTrace(
              stepLogList,
              prevLastStep.getStepInfo().getPath()); // recursive, find the child last step
    } else {
      return new ArrayList<StepLog>(); // no more steps inside
    }
    stackTrace.add(prevLastStep); // add current last step to stack trace
    return stackTrace;
  }
  public String stackTraceAsString(List<StepLog> stackTrace) {
    String stackTraceString = "\n<font color=\"red\"><b>";

    String indent = "   ";
    String indentation = indent;

    for (StepLog stepLog : Lists.reverse(stackTrace)) {
      stackTraceString +=
          stepLog.getStepInfo().getStepName()
              + " - "
              + stepLog.getStepInfo().getResponseType()
              + "\n"
              + indentation;
      indentation = indentation + indent;
    }

    StepLog lastStep = stackTrace.get(stackTrace.size() - 1);
    indentation = indentation.substring(0, indentation.length() - 1 - indent.length());
    stackTraceString += "\n" + indentation;

    // Add raw results
    stackTraceString += "RAW Results: " + lastStep.getRawResult() + "\n" + indentation;

    // Add step inputs
    Map<String, String> stepInputs = new HashMap<String, String>();
    for (RecordBoundInputVO recordBoundInputVO : lastStep.getStepInputs()) {
      stepInputs.put(recordBoundInputVO.getName(), recordBoundInputVO.getValue());
    }
    stackTraceString += "Step Inputs: " + stepInputs + "\n";

    stackTraceString += "</b></font>\n\n";
    return stackTraceString;
  }