private void cleanUpFrontier(){
  while (!frontier.isEmpty() && isExplored(frontier.element()))   frontier.remove();
}

private void cleanUpFrontier ( ) { while ( ! frontier . isEmpty ( ) && isExplored ( frontier . element ( ) ) ) frontier . remove ( ) ; }
helper method which removes nodes of already explored states from the head of the frontier .
