public Node[] getNodes(boolean optimal) {
   if (optimal) {
     Node[] garbage = super.getNodes(false);
     task.waitFinished();
   }
   return super.getNodes(false);
 }
  public void testGetFileWhileClosingProject() throws Exception {

    File projectRoot = getDataFile("quote_nosyshdr");

    int count = Integer.getInteger("test.get.file.while.closing.project.laps", 500);

    final TraceModelBase traceModel = new TraceModelBase(true);
    traceModel.processArguments(projectRoot.getAbsolutePath());
    ModelImpl model = traceModel.getModel();

    List<String> files = new ArrayList<String>(traceModel.getFiles().size());
    for (File file : traceModel.getFiles()) {
      files.add(file.getAbsolutePath());
    }

    for (int i = 0; i < count; i++) {

      System.err.printf(
          "%s: processing project %s. Pass %d \n",
          getBriefClassName(), projectRoot.getAbsolutePath(), i);

      final CsmProject project = traceModel.getProject();
      project.waitParse();
      RequestProcessor.Task task =
          model.enqueueModelTask(
              new Runnable() {

                @Override
                public void run() {
                  TraceModelBase.closeProject(project);
                }
              },
              "Closing Project " + i); // NOI18N
      for (String path : files) {
        try {
          CsmFile csmFile = project.findFile(path, true, false);
          if (verbose) {
            System.err.printf("\tfind %s -> %s \n", path, csmFile);
          }
        } catch (Throwable e) {
          registerException(e);
        }
        assertNoExceptions();
      }
      if (verbose) {
        System.err.printf("Waiting util close task finishes...\n");
      }
      task.waitFinished();
      if (verbose) {
        System.err.printf("\tClose task has finished.\n");
      }
      assertNoExceptions();
      traceModel.resetProject();
    }
    assertNoExceptions();
  }