Filtering untagged referenced objects with osm2pgsql

I want to filter all nodes and ways that have highway tag along with untagged nodes and ways that are referenced in already filtered highway ways and relations with osm2pgsql’s Lua style file but it seems not possible since the objects are processed in certain order. I know I can use osmium tags-filter for that, but I’m trying to avoid using additional tools.
Will I have to use it anyways or is it actually possible to do with the style files?
Thanks in advance :slight_smile:

I think there might be some misunderstanding on how osm2pgsql works. It is easy to get all nodes and ways tagged as highway. You don´t have to think about the nodes needed for the ways, because osm2pgsql takes care of that for you. But you will not get those nodes in the resulting database, the nodes will be used in creating the geometry for the object imported into the database.

Maybe you can explain what goal you want to achieve in the end, then we can better help you with ways to get there.