How can I implement such a thing?
Similarly to what you have linked but using OSM node instead of way ids.
Do I have to store and retrieve node IDs manually?
Currently yes. You can use any storage or in-memory solution like MapDB.
BTW: Any contribution in this regard would be highly appreciated.