def _get_axis(self, name_or_index: AxisIdentifier) -> int:
        """Get a zero-based index of an axis and check its existence."""
        # TODO: Add unit test
        if isinstance(name_or_index, int):
            if name_or_index < 0 or name_or_index >= self.ndim:
                raise ValueError("No such axis, must be from 0 to {0}".format(self.ndim-1))
            return name_or_index
        elif isinstance(name_or_index, str):
            if name_or_index not in self.axis_names:
                named_axes = [name for name in self.axis_names if name]
                raise ValueError("No axis with such name: {0}, available names: {1}. In most places, you can also use numbers."
                                   .format(name_or_index, ", ".join(named_axes)))
            return self.axis_names.index(name_or_index)
        else:
            raise TypeError("Argument of type {0} not understood, int or str expected.".format(type(name_or_index)))
Get a zero-based index of an axis and check its existence.