add warning logging in getFirstElement and getLastElement for null and
empty lists