def __getitem__(self, i):
"""Returns the element at index i of the list,
or throws an IndexError if index is too large."""
if self._isEmpty():
raise IndexError('list index out of range')
elif i == 0:
return self._head
else:
return self._rest[i-1] # recurse