Way nodes degree

Hi,
I’m tryng to process osm data to build a graph with osm2pgsql. In particular I need the degree of all the nodes of ways tagged as highway.
To do this I use a local table in process_way to store the degree of nodes like this:

local junctions = {}

function osm2pgsql.process_way(object)
    if handlers.check_filter_highway(object) then
        return
    end

    utils.clean_tags(object.tags)
  
    for _, node in ipairs(object.nodes) do
        if not junctions[node] then
            junctions[node] = 1
        else
            junctions[node] = junctions[node] + 1
        end
    end 
   ...         

At the end of process_way the table contains node ids and node degrees and would like to reprocess these nodes and store them in the db.

Is there a way to mark way nodes to reprocess in a similar way to using select_relation_members for relations nodes?