def _maybe_convert_i8(self, key):
original = key<EOL>if is_list_like(key):<EOL><INDENT>key = ensure_index(key)<EOL><DEDENT>if not self._needs_i8_conversion(key):<EOL><INDENT>return original<EOL><DEDENT>scalar = is_scalar(key)<EOL>if is_interval_dtype(key) or isinstance(key, Interval):<EOL><INDENT>left = self._maybe_convert_i8(key.left)<EOL>right = self._maybe_convert_i8(key.right)<EOL>constructor = Interval if scalar else IntervalIndex.from_arrays<EOL>return constructor(left, right, closed=self.closed)<EOL><DEDENT>if scalar:<EOL><INDENT>key_dtype, key_i8 = infer_dtype_from_scalar(key, pandas_dtype=True)<EOL><DEDENT>else:<EOL><INDENT>key_dtype, key_i8 = key.dtype, Index(key.asi8)<EOL>if key.hasnans:<EOL><INDENT>key_i8 = key_i8.where(~key._isnan)<EOL><DEDENT><DEDENT>subtype = self.dtype.subtype<EOL>msg = ('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>if not is_dtype_equal(subtype, key_dtype):<EOL><INDENT>raise ValueError(msg.format(subtype=subtype, other=key_dtype))<EOL><DEDENT>return key_i8<EOL>
Maybe convert a given key to it's equivalent i8 value(s). Used as a
preprocessing step prior to IntervalTree queries (self._engine), which
expects numeric data.

Parameters
----------
key : scalar or list-like
    The key that should maybe be converted to i8.

Returns
-------
key: scalar or list-like
    The original key if no conversion occured, int if converted scalar,
    Int64Index if converted list-like.