function _findUnit(str) {
    // First, match units names exactly. For example, a user could define 'mm' as 10^-4 m, which is silly, but then we would want 'mm' to match the user-defined unit.
    if (UNITS.hasOwnProperty(str)) {
      var unit = UNITS[str];
      var prefix = unit.prefixes[''];
      return {
        unit: unit,
        prefix: prefix
      };
    }

    for (var name in UNITS) {
      if (UNITS.hasOwnProperty(name)) {
        if (endsWith(str, name)) {
          var _unit = UNITS[name];
          var prefixLen = str.length - name.length;
          var prefixName = str.substring(0, prefixLen);

          var _prefix = _unit.prefixes.hasOwnProperty(prefixName) ? _unit.prefixes[prefixName] : undefined;

          if (_prefix !== undefined) {
            // store unit, prefix, and value
            return {
              unit: _unit,
              prefix: _prefix
            };
          }
        }
      }
    }

    return null;
  }
Find a unit from a string
@memberof Unit
@param {string} str              A string like 'cm' or 'inch'
@returns {Object | null} result  When found, an object with fields unit and
                                 prefix is returned. Else, null is returned.
@private