Function to find the count of pairs such that the minimum distance between them is equal to the difference between distance of the nodes from root node
function countPairs ( edges ) { for ( var i = 0 ; i < edges . length ; i ++ ) { var u = edges [ i ] [ 0 ] ; var v = edges [ i ] [ 1 ] ;