Rework r269444 to work also for lists without IDs.

MFC after:	3 days

(cherry picked from commit 7dab858aad63d1b1f2c1131f12c0f128c822f44b)