docs: protected Query[] buildPrefetchQueries(Collection proxies, Collection realSubjects)
      {
          Collection queries = new ArrayList();
          Collection idsSubset;
          Object proxy;
          IndirectionHandler handler;
          Identity id;
          Class realClass;
          HashMap classToIds = new HashMap();
          Class topLevelClass = getItemClassDescriptor().getClassOfObject();
          PersistenceBroker pb = getBroker();
          ObjectCache cache = pb.serviceObjectCache();
  
          for (Iterator it = proxies.iterator(); it.hasNext(); )
          {
              proxy = it.next();
              handler = ProxyHelper.getIndirectionHandler(proxy);
  
              if (handler == null)
              {
                  continue;
              }
              
              id = handler.getIdentity();
              if (cache.lookup(id) != null)
              {
                  realSubjects.add(pb.getObjectByIdentity(id));
                  continue;
              }
              realClass = id.getObjectsRealClass();
              if (realClass == null)
              {
                  realClass = Object.class; // to remember that the real class is unknown
              }
              idsSubset = (HashSet) classToIds.get(realClass);
              if (idsSubset == null)
              {
                  idsSubset = new HashSet();
                  classToIds.put(realClass, idsSubset);
              }
              idsSubset.add(id);
              if (idsSubset.size() == pkLimit)
              {
                  Query query;
                  if (realClass == Object.class)
                  {
                      query = buildPrefetchQuery(topLevelClass, idsSubset, true);
                  }
                  else
                  {
                      query = buildPrefetchQuery(realClass, idsSubset, false);
                  }
                  queries.add(query);
                  idsSubset.clear();
              }
          }
  
          for (Iterator it = classToIds.entrySet().iterator(); it.hasNext(); )
          {
              Map.Entry entry = (Map.Entry) it.next();
              realClass = (Class) entry.getKey();
              idsSubset = (HashSet) entry.getValue();
              if (idsSubset.size() > 0)
              {
                  Query query;
                  if (realClass == Object.class)
                  {
                      query = buildPrefetchQuery(topLevelClass, idsSubset, true);
                  }
                  else
                  {
                      query = buildPrefetchQuery(realClass, idsSubset, false);
                  }
                  queries.add(query);
              }
          }
  
          return (Query[]) queries.toArray(new Query[queries.size()]);
      }