private List<String> matchAlmostRecursion(TSTNode currentNode,int charIndex,int d,CharSequence matchAlmostKey,int matchAlmostNumReturnValues,List<String> matchAlmostResult2,boolean upTo){
  if ((currentNode == null) || (matchAlmostNumReturnValues != -1 && matchAlmostResult2.size() >= matchAlmostNumReturnValues) || (d < 0)|| (charIndex >= matchAlmostKey.length())) {
    return matchAlmostResult2;
  }
  int charComp=compareCharsAlphabetically(matchAlmostKey.charAt(charIndex),currentNode.splitchar);
  List<String> matchAlmostResult=matchAlmostResult2;
  if ((d > 0) || (charComp < 0)) {
    matchAlmostResult=matchAlmostRecursion(currentNode.relatives[TSTNode.LOKID],charIndex,d,matchAlmostKey,matchAlmostNumReturnValues,matchAlmostResult,upTo);
  }
  int nextD=(charComp == 0) ? d : d - 1;
  boolean cond=(upTo) ? (nextD >= 0) : (nextD == 0);
  if ((matchAlmostKey.length() == charIndex + 1) && cond && (currentNode.data != null)) {
    matchAlmostResult.add(getKey(currentNode));
  }
  matchAlmostResult=matchAlmostRecursion(currentNode.relatives[TSTNode.EQKID],charIndex + 1,nextD,matchAlmostKey,matchAlmostNumReturnValues,matchAlmostResult,upTo);
  if ((d > 0) || (charComp > 0)) {
    matchAlmostResult=matchAlmostRecursion(currentNode.relatives[TSTNode.HIKID],charIndex,d,matchAlmostKey,matchAlmostNumReturnValues,matchAlmostResult,upTo);
  }
  return matchAlmostResult;
}

private List < String > matchAlmostRecursion ( TSTNode currentNode , int charIndex , int d , CharSequence matchAlmostKey , int matchAlmostNumReturnValues , List < String > matchAlmostResult2 , boolean upTo ) { if ( ( currentNode == null ) || ( matchAlmostNumReturnValues != - 1 && matchAlmostResult2 . size ( ) >= matchAlmostNumReturnValues ) || ( d < 0 ) || ( charIndex >= matchAlmostKey . length ( ) ) ) { return matchAlmostResult2 ; } int charComp = compareCharsAlphabetically ( matchAlmostKey . charAt ( charIndex ) , currentNode . splitchar ) ; List < String > matchAlmostResult = matchAlmostResult2 ; if ( ( d > 0 ) || ( charComp < 0 ) ) { matchAlmostResult = matchAlmostRecursion ( currentNode . relatives [ TSTNode . LOKID ] , charIndex , d , matchAlmostKey , matchAlmostNumReturnValues , matchAlmostResult , upTo ) ; } int nextD = ( charComp == 0 ) ? d : d - 1 ; boolean cond = ( upTo ) ? ( nextD >= 0 ) : ( nextD == 0 ) ; if ( ( matchAlmostKey . length ( ) == charIndex + 1 ) && cond && ( currentNode . data != null ) ) { matchAlmostResult . add ( getKey ( currentNode ) ) ; } matchAlmostResult = matchAlmostRecursion ( currentNode . relatives [ TSTNode . EQKID ] , charIndex + 1 , nextD , matchAlmostKey , matchAlmostNumReturnValues , matchAlmostResult , upTo ) ; if ( ( d > 0 ) || ( charComp > 0 ) ) { matchAlmostResult = matchAlmostRecursion ( currentNode . relatives [ TSTNode . HIKID ] , charIndex , d , matchAlmostKey , matchAlmostNumReturnValues , matchAlmostResult , upTo ) ; } return matchAlmostResult ; }
recursivelly vists the nodes in order to find the ones that almost match a given key .
