function _buildIriMap($iri_map, $key, $idx) {
    $entries = $iri_map[$key];
    $next = $iri_map[$key] = new ArrayObject();

    foreach($entries as $entry) {
      $iri = $entry->iri;
      if($idx >= strlen($iri)) {
        $letter = '';
      } else {
        $letter = $iri[$idx];
      }
      if(!isset($next[$letter])) {
        $next[$letter] = new ArrayObject();
      }
      $next[$letter][] = $entry;
    }

    foreach($next as $key => $value) {
      if($key === '') {
        continue;
      }
      $this->_buildIriMap($next, $key, $idx + 1);
    }
  }