protected static FastVector pruneCadidates(FastVector allCandidates, FastVector kMinusOneSequences) {
    FastVector prunedCandidates = new FastVector();
    boolean isFrequent;
    //for each candidate
    for (int i = 0; i < allCandidates.size(); i++) {
      Sequence candidate = (Sequence) allCandidates.elementAt(i);
      isFrequent = true;
      FastVector canElements = candidate.getElements();
      //generate each possible (k-1)-sequence and verify if it's frequent
      for (int j = 0; j < canElements.size(); j++) {
	if(isFrequent) {
	  Element origElement = (Element) canElements.elementAt(j);
	  int[] origEvents = origElement.getEvents();

	  for (int k = 0; k < origEvents.length; k++) {
	    if (origEvents[k] > -1) {
	      int helpEvent = origEvents[k];
	      origEvents[k] = -1;

	      if (origElement.isEmpty()) {
		canElements.removeElementAt(j);
		//check if the (k-1)-sequence is contained in the set of kMinusOneSequences
		int containedAt = kMinusOneSequences.indexOf(candidate);
		if (containedAt != -1) {
		  origEvents[k] = helpEvent;
		  canElements.insertElementAt(origElement, j);
		  break;
		} else {
		  isFrequent = false;
		  break;
		}
	      } else {
		//check if the (k-1)-sequence is contained in the set of kMinusOneSequences
		int containedAt = kMinusOneSequences.indexOf(candidate);
		if (containedAt != -1) {
		  origEvents[k] = helpEvent;
		  continue;
		} else {
		  isFrequent = false;
		  break;
		}
	      }
	    }
	  }
	} else {
	  break;
	}
      }
      if (isFrequent) {
	prunedCandidates.addElement(candidate);
      }
    }
    return prunedCandidates;
  }