pkg: add generic linked list iterator code