[Python] DFS
\nclass Solution(object):\n    def countHighestScoreNodes(self, parents):\n        """\n        :type parents: List[int]\n        :rtype: int\n        """\n    
```\nclass Solution(object):\n    def countHighestScoreNodes(self, parents):\n        """\n        :type parents: List[int]\n        :rtype: int\n        """\n        hmap = collections.defaultdict(list)\n        n = len(parents)\n        for i in range(n):\n            if parents[i] != -1:\n                hmap[parents[i]].append(i)\n        \n        self.maxKey, self.res = 0, 0\n        \n        def dfs(node):\n            score = 1\n            count = 0\n            for nxt in hmap[node]:\n                subCount = dfs(nxt)\n                score*=subCount\n                count += subCount\n            \n            score *= n-1-count or 1\n            \n            if score > self.maxKey:\n                self.maxKey = score\n                self.res = 1\n            elif score == self.maxKey:\n                self.res += 1\n            \n            return count + 1\n        \n        dfs(0)\n\n        return self.res\n```
[]