FWIW, this magic is how the Linux kernel implements generic linked lists, hash tables, and red-black trees:
https://stackoverflow.com/questions/15832301/understanding-c...
https://stackoverflow.com/questions/15832301/understanding-c...
EDIT: check out some examples to see for yourself: https://elixir.bootlin.com/linux/latest/ident/hlist_add_head