How do I retrieve value from last node in a set?

I am trying to write a program to create a new ID for a document based on the last entry in my Tamino DB. How do I get the last node only, not the whole node set like I get when I use last().

Thanks

Knute Hestness