Related to Getting a unique ID for each node (that doesnt change)
Although it is possible to fetch the number of threads, this does not guarantee the goal because your node may have a link node as input and in this case you would have to do further research. Which implies quite substantial logic.
In short, the cleanest method would be to use topics