How do I determine if a database restore file should be restored to the database based on backupset?
There is an msdb table that contains the restore history:

select  * 
from    msdb.dbo.restorehistory rh


For a database, you can look up the date of the last restore.  If you can determine the date of the incoming restore (typically the restore date is part of the file name) you could compare the two.

While this safeguards against overwriting newer restores with older ones, it's not ideal.  There can be a difference between the backup date and the restore date, and newer restores that fall in between will be ignored.

You could improve that if you knew the filename that the last restore came from, but I can't find that information in the msdb tables.