getLookupTable = (col, lookupKey) => {

  col = getIterableCollection(col);

  const lookupTable = basicUtils.makeHashMap();
  const keys = Object.keys(col);

  for (let i = 0, l = keys.length; i < l; i++) {

    const key = keys[i];
    const idx = (lookupKey ? col[key][lookupKey] : col[key]);
    const type = typeof idx;

    if ((type === 'string' && idx !== '') || type === 'number') {
      if (!lookupTable[idx]) { // doesn't exist yet!
        lookupTable[idx] = (lookupKey ? col[key] : true);
        continue;
      }
    }

    // only throw if lookupKey is set to avoid crash if duplicates exist in col
    // Solves: https://github.com/felixhayashi/TW5-TiddlyMap/issues/327
    if (lookupKey) {
      // @todo use exception class
      throw new Error(`Cannot use "${idx}" as lookup table index`);
    }

  }

  return lookupTable;

}
In a collection where all elements have a **distinct** property
`lookupKey`, use the value of each element's `lookupKey` as key
to identify the object. If no property `lookupKey` is specified,
the collection's values are used as keys and `true` is used as value,
however, if the used keys are not strings, an error is thrown.

@param {Collection} col - The collection for which to create a lookup table.
@param {string} [lookupKey] - The property name to use as index in
    the lookup table. If not specified, the collection values are tried
    to be used as indeces.
@return {Hashmap} The lookup table.