Get the first and last elements in a list from any node in constant time