Java solution fail. what's wrong?
\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        HashMap<Integer, TreeNode> treeMap = new HashMap<Integer, TreeNode>();\n    
```\nclass Solution {\n    public int countHighestScoreNodes(int[] parents) {\n        HashMap<Integer, TreeNode> treeMap = new HashMap<Integer, TreeNode>();\n        for (int i = 0; i < parents.length; i++) {\n            TreeNode node;\n            if (!treeMap.containsKey(i)) {\n                node = new TreeNode(i);\n                treeMap.put(i, node);\n            } else {\n                node = treeMap.get(i);\n            }\n            if (parents[i] == -1) {\n                continue;\n            }\n            if (!treeMap.containsKey(parents[i])) {\n                TreeNode parent = new TreeNode(parents[i]);\n                treeMap.put(parents[i], parent);\n                parent.setChild(node);\n            } else {\n                TreeNode parent = treeMap.get(parents[i]);\n                parent.setChild(node);\n            }\n        }\n\n        TreeNode root = treeMap.get(0);\n        int score = setScoreForNodes(root);\n        System.out.println(score);\n        System.out.println(parents.length);\n\n        int cnt = 0;\n        int maxProduct = 0;\n        for (int i = 0; i < parents.length; i++) {\n            TreeNode node = treeMap.get(i);\n            int leftScore = node.left == null? 0 : node.left.score;\n            int rightScore = node.right == null? 0 : node.right.score;\n            int otherPartScore = score - node.score;\n            leftScore = Math.max(leftScore, 1);\n            rightScore = Math.max(rightScore, 1);\n            otherPartScore = Math.max(otherPartScore, 1);\n            int total = leftScore * rightScore * otherPartScore;\n            if (total == maxProduct) {\n                cnt += 1;\n            } else if (total > maxProduct) {\n                maxProduct = total;\n                cnt = 1;\n            }\n        }\n        return cnt;\n    }\n\n    public int setScoreForNodes(TreeNode root) {\n        if (Objects.isNull(root)) {\n            return 0;\n        }\n        int score = 1 + setScoreForNodes(root.left) + setScoreForNodes(root.right);\n        root.score = score;\n        return score;\n    }\n\n    class TreeNode {\n         int val;\n         int score;\n         TreeNode left;\n         TreeNode right;\n\n        public TreeNode(int val) {\n            this.val = val;\n            return;\n        }\n\n        public void setChild(TreeNode node) {\n            if (this.left == null) {\n                this.left = node;\n            } else {\n                this.right = node;\n            }\n            return;\n        }\n    }\n}\n```
[]