if (leftSubcats.size() > 0 && rightSubcats.size() > 0) {
int numLeftSubcats = leftSubcats.size(); int numRightSubcats = rightSubcats.size(); if (numLeftSubcats > 0 && numRightSubcats > 0) {
  protected List addUnaries(CKYItem item, List itemsAdded)  throws RemoteException {    unaryItemsToAdd.clear();    CKYItem newItem = chart.getNewItem();    newItem.set(null, item.headWord(), null, null, item,                null, null, startList, startList,                item.start(), item.end(),                false, false, false, 0.0, 0.0, 0.0);    Symbol headSym = (Symbol)item.label();    HeadEvent headEvent = lookupHeadEvent;    headEvent.set(item.headWord(), null, headSym, emptySubcat, emptySubcat);    PriorEvent priorEvent = lookupPriorEvent;    priorEvent.set(item.headWord(), null);    // foreach nonterminal    for (int ntIndex = 0; ntIndex < nonterminals.length; ntIndex++) {      Symbol parent = nonterminals[ntIndex];      headEvent.setParent(parent);      Set leftSubcats = getPossibleSubcats(leftSubcatMap, headEvent,                                           leftSubcatPS,                                           leftSubcatPSLastLevel);      Set rightSubcats = getPossibleSubcats(rightSubcatMap, headEvent,                                            rightSubcatPS,                                            rightSubcatPSLastLevel);      if (debugUnaries) {      }      if (leftSubcats.size() > 0 && rightSubcats.size() > 0) {        Iterator leftSubcatIt = leftSubcats.iterator();        // foreach possible left subcat        while (leftSubcatIt.hasNext()) {          Subcat leftSubcat = (Subcat)leftSubcatIt.next();          Iterator rightSubcatIt = rightSubcats.iterator();          // foreach possible right subcat          while (rightSubcatIt.hasNext()) {            Subcat rightSubcat = (Subcat)rightSubcatIt.next();            newItem.setLabel(parent);            newItem.setLeftSubcat(leftSubcat);            newItem.setRightSubcat(rightSubcat);            headEvent.setLeftSubcat(leftSubcat);            headEvent.setRightSubcat(rightSubcat);            if (debugUnaries) {            }            double logProbHead = server.logProbHead(id, headEvent);            if (logProbHead <= Constants.logOfZero)              continue;            double logTreeProb =              item.logTreeProb() + logProbHead;	    priorEvent.setLabel(parent);            double logPrior = server.logPrior(id, priorEvent);            if (logPrior <= Constants.logOfZero)              continue;            double logProb = logTreeProb + logPrior;            if (debugUnaries) {            }            if (logProb <= Constants.logOfZero)              continue;            newItem.setLogTreeProb(logTreeProb);            newItem.setLogPrior(logPrior);            newItem.setLogProb(logProb);            CKYItem newItemCopy = chart.getNewItem();            newItemCopy.setDataFrom(newItem);            unaryItemsToAdd.add(newItemCopy);          }        } // end foreach possible left subcat      }    }    Iterator toAdd = unaryItemsToAdd.iterator();    while (toAdd.hasNext()) {      CKYItem itemToAdd = (CKYItem)toAdd.next();      boolean added = chart.add(itemToAdd.start(), itemToAdd.end(), itemToAdd);      if (added)        itemsAdded.add(itemToAdd);      else        chart.reclaimItem(itemToAdd);    }    chart.reclaimItem(newItem);    return itemsAdded;  }