if (VERBOSE) { System.out.println( "\n*****************************************************"+ "\nSEARCH UP"+ ((limit >= 0) ? ("\nLimit: "+limit) : "\nNo limit"));
if (VERBOSE) { System.out.println( "\n*****************************************************"+ "\nSEARCH UP"+ ((limit >= 0) ? ("\nLimit: "+limit) : "\nNo limit")); }   WorkStack ws = new WorkStack(); Set findUIDSet = new HashSet(startUIDSet);  search_up_loop: while (!(findUIDSet.isEmpty())) {  if (VERBOSE) { System.out.println( "\nFind ["+findUIDSet.size()+"]: "+findUIDSet); }   Collection foundCol = findUniqueObjects( support, findUIDSet); findUIDSet.clear();  if (VERBOSE) { System.out.println( "Found "+foundCol.size()+" of "+findUIDSet.size()); }  ws.pushAll(foundCol);  while (ws.hasWork()) { UniqueObject uo = ws.take();  if (uo instanceof PlanElement) {  PlanElement pe = (PlanElement)uo;  ws.push(pe.getTask());  } else if (uo instanceof Task) {   if (uo instanceof MPTask) { MPTask mpt = (MPTask)uo;  ws.pushAll(mpt.getParentTasks()); } else { Task t = (Task)uo;  ClusterIdentifier tCID = t.getSource(); if ((tCID == null) || (localCID.equals(tCID))) {  UID uid = t.getParentTaskUID(); if ((uid != null) && (!(ws.hasPushedKey(uid)))) {      findUIDSet.add(uid); } } else {  } }  } else if (uo instanceof Workflow) {  Workflow wf = (Workflow)uo;  ws.push(wf.getParentTask());  } else {  }  if (ws.sizePushed() > limit) {    break search_up_loop; } } }  if (VERBOSE) { System.out.println( "done."+ "\n****************************************************\n"); }  List toL = new ArrayList(ws.sizePushed()); ws.toCollection(toL); return toL;
  private static List searchUp(			       SimpleServletSupport support, 			       Set startUIDSet,			       int limit) {        // get this Cluster's identifier    ClusterIdentifier localCID =      support.getAgentIdentifier();        if (VERBOSE) {      System.out.println(			 "\n*****************************************************"+			 "\nSEARCH UP"+			 ((limit >= 0) ? ("\nLimit: "+limit) : "\nNo limit"));    }        // make a list of Objs to search    WorkStack ws = new WorkStack();    Set findUIDSet = new HashSet(startUIDSet);      search_up_loop:    while (!(findUIDSet.isEmpty())) {            if (VERBOSE) {        System.out.println(			   "\nFind ["+findUIDSet.size()+"]: "+findUIDSet);      }            // find the starting objects      Collection foundCol =        findUniqueObjects(			  support, 			  findUIDSet);      findUIDSet.clear();            if (VERBOSE) {        System.out.println(			   "Found "+foundCol.size()+" of "+findUIDSet.size());      }            ws.pushAll(foundCol);            while (ws.hasWork()) {        UniqueObject uo = ws.take();        //        if (uo instanceof PlanElement) {	            PlanElement pe = (PlanElement)uo;          // task          ws.push(pe.getTask());	          } else if (uo instanceof Task) {	            // task parent(s)          if (uo instanceof MPTask) {            MPTask mpt = (MPTask)uo;            // parent tasks            ws.pushAll(mpt.getParentTasks());          } else {            Task t = (Task)uo;            // only have a UID for the parent            ClusterIdentifier tCID = t.getSource();            if ((tCID == null) ||                (localCID.equals(tCID))) {              // local Task, must search by UID              UID uid = t.getParentTaskUID();              if ((uid != null) &&                  (!(ws.hasPushedKey(uid)))) {                // add the UID to next search pass.                //                // note that this "find" Task may be found in                // this pass indirectly, which will waste a query,                // but it's a rare and harmless situation                findUIDSet.add(uid);              }            } else {              // remote up!            }          }	          } else if (uo instanceof Workflow) {	            Workflow wf = (Workflow)uo;          // task          ws.push(wf.getParentTask());	          } else {          // ignore        }	        if (ws.sizePushed() > limit) {          // we've exceeded our limit          //          // FIXME: trim "ws" to just (limit + 1)          break search_up_loop;        }      }    }    if (VERBOSE) {      System.out.println(			 "done."+			 "\n****************************************************\n");    }        List toL = new ArrayList(ws.sizePushed());    ws.toCollection(toL);    return toL;  }