/**
  *
  */
 public static function prefetchAllRelatedIDs($po_nodes, $ps_tablename, $pa_row_ids, $pa_options = null)
 {
     foreach ($po_nodes as $vn_index => $o_node) {
         switch ($vs_tag = $o_node->tag) {
             case 'unit':
                 if ($vs_relative_to = $o_node->relativeTo) {
                     $va_get_options = ['returnAsArray' => true, 'checkAccess' => caGetOption('checkAccess', $pa_options, null)];
                     $va_get_options['restrictToTypes'] = DisplayTemplateParser::_getCodesFromAttribute($o_node, ['attribute' => 'restrictToTypes']);
                     $va_get_options['excludeTypes'] = DisplayTemplateParser::_getCodesFromAttribute($o_node, ['attribute' => 'excludeTypes']);
                     $va_get_options['restrictToRelationshipTypes'] = DisplayTemplateParser::_getCodesFromAttribute($o_node, ['attribute' => 'restrictToRelationshipTypes']);
                     $va_get_options['excludeRelationshipTypes'] = DisplayTemplateParser::_getCodesFromAttribute($o_node, ['attribute' => 'excludeRelationshipTypes']);
                     $va_search_result_opts = array();
                     if ($o_node->includeNonPrimaryRepresentations) {
                         $va_search_result_opts['filterNonPrimaryRepresentations'] = false;
                     }
                     if ($o_node->sort) {
                         $va_get_options['sort'] = preg_split('![ ,;]+!', $o_node->sort);
                         $va_get_options['sortDirection'] = $o_node->sortDirection;
                     }
                     try {
                         $va_row_ids = DisplayTemplateParser::_getRelativeIDsForRowIDs($ps_tablename, $vs_relative_to, $pa_row_ids, 'related', $va_get_options);
                         if (!sizeof($va_row_ids)) {
                             return;
                         }
                         $qr_res = caMakeSearchResult($ps_tablename, $va_row_ids, $va_search_result_opts);
                         if (!$qr_res) {
                             return;
                         }
                         $va_cache_opts = $qr_res->get($vs_relative_to . "." . $qr_res->primaryKey(), array_merge($va_get_options, ['returnCacheOptions' => true]));
                         $qr_res->prefetchRelated($vs_relative_to, 0, $qr_res->getOption('prefetch'), $va_cache_opts);
                         if ($o_node->children) {
                             DisplayTemplateParser::prefetchAllRelatedIDs($o_node->children, $vs_relative_to, $va_row_ids, $pa_options);
                         }
                     } catch (Exception $e) {
                         // prefetch failed
                     }
                 }
                 break;
         }
     }
 }