The normal approach is to count by how many highways a node is referenced. Closed ways or P-shaped ways are special cases. A node that is referenced more than once is a junction node.