Here's the technical low-down if you're interested.
A program called Reclamator runs in the background. This program watches all entries that appear in the Trash. An item appears in the Trash when you press "delete" or "ctrl-T" to move it to the Trash.
When an item appears in the Trash, Reclamator tags this item with the following attributes:
When you run the Undelete add-on on an item in the Trash, Undelete reads the Deleted From and Original Name attributes so it knows where to restore the item to. If Reclamator wasn't running while the item was moved to the Trash, these attributes won't be present and Undelete won't know where to restore the item to.
If you open a folder that is in the Trash, the items in the folder do not have the extra attributes that Reclamator adds to items in the Trash.  This is because Reclamator would have to add thousands of attributes to thousands of files if you removed a folder which contained thousands of entries. You can still undelete items from sub-folders in the Trash however, because Undelete walks up the folder hierarchy until it gets to the top folder in the Trash, from whose attributes it knows where to restore the items to.