<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _add_edges(self, ast_node, trunk=None):
 """"Add all bonds in the SMARTS string as edges in the graph."""

        atom_indices = self._atom_indices
        for atom in ast_node.tail:
            if atom.head == 'atom':
                atom_idx = atom_indices[id(atom)]
                if atom.is_first_kid and atom.parent().head == 'branch':
                    trunk_idx = atom_indices[id(trunk)]
                    self.add_edge(atom_idx, trunk_idx)
                if not atom.is_last_kid:
                    if atom.next_kid.head == 'atom':
                        next_idx = atom_indices[id(atom.next_kid)]
                        self.add_edge(atom_idx, next_idx)
                    elif atom.next_kid.head == 'branch':
                        trunk = atom
                else:  # We traveled through the whole branch.
                    return
            elif atom.head == 'branch':
                self._add_edges(atom, trunk)