<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parse_branches(self, branchset_node, branchset, validate):
 """ Create and attach branches at ``branchset_node`` to ``branchset``. :param branchset_node: Same as for :meth:`parse_branchset`. :param branchset: An instance of :class:`BranchSet`. :param validate: Whether or not branches' uncertainty values should be validated. Checks that each branch has :meth:`valid <validate_uncertainty_value>` value, unique id and that all branches have total weight of 1.0. :return: ``None``, all branches are attached to provided branchset. """

        weight_sum = 0
        branches = branchset_node.nodes
        values = []
        for branchnode in branches:
            weight = ~branchnode.uncertaintyWeight
            weight_sum += weight
            value_node = node_from_elem(branchnode.uncertaintyModel)
            if value_node.text is not None:
                values.append(value_node.text.strip())
            if validate:
                self.validate_uncertainty_value(
                    value_node, branchnode, branchset)
            value = self.parse_uncertainty_value(value_node, branchset)
            branch_id = branchnode.attrib.get('branchID')
            branch = Branch(branch_id, weight, value)
            if branch_id in self.branches:
                raise LogicTreeError(
                    branchnode, self.filename,
                    "branchID '%s' is not unique" % branch_id)
            self.branches[branch_id] = branch
            branchset.branches.append(branch)
        if abs(weight_sum - 1.0) > pmf.PRECISION:
            raise LogicTreeError(
                branchset_node, self.filename,
                "branchset weights don't sum up to 1.0")
        if len(set(values)) < len(values):
            # TODO: add a test for this case
            # <logicTreeBranch branchID="b71">
            #     <uncertaintyModel> 7.7 </uncertaintyModel>
            #     <uncertaintyWeight>0.333</uncertaintyWeight>
            # </logicTreeBranch>
            # <logicTreeBranch branchID="b72">
            #     <uncertaintyModel> 7.695 </uncertaintyModel>
            #     <uncertaintyWeight>0.333</uncertaintyWeight>
            # </logicTreeBranch>
            # <logicTreeBranch branchID="b73">
            #     <uncertaintyModel> 7.7 </uncertaintyModel>
            #     <uncertaintyWeight>0.334</uncertaintyWeight>
            # </logicTreeBranch>
            raise LogicTreeError(
                branchset_node, self.filename,
                "there are duplicate values in uncertaintyModel: " +
                ' '.join(values))