<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_undirected(self, reciprocal=False):
 """Return an undirected representation of the dyndigraph. Parameters reciprocal : bool (optional) If True only keep edges that appear in both directions in the original dyndigraph. Returns ------- G : DynGraph An undirected dynamic graph with the same name and nodes and with edge (u,v,data) if either (u,v,data) or (v,u,data) is in the dyndigraph. If both edges exist in dyndigraph and their edge data is different, only one edge is created with an arbitrary choice of which edge data to use. You must check and correct for this manually if desired. Notes ----- If edges in both directions (u,v) and (v,u) exist in the graph, attributes for the new undirected edge will be a combination of the attributes of the directed edges. The edge data is updated in the (arbitrary) order that the edges are encountered. For more customized control of the edge attributes use add_edge(). This returns a "deepcopy" of the edge, node, and graph attributes which attempts to completely copy all of the data and references. This is in contrast to the similar G=DynDiGraph(D) which returns a shallow copy of the data. See the Python copy module for more information on shallow and deep copies, http://docs.python.org/library/copy.html. Warning: If you have subclassed DiGraph to use dict-like objects in the data structure, those changes do not transfer to the Graph created by this method. """

        from .dyngraph import DynGraph
        H = DynGraph()
        H.name = self.name
        H.add_nodes_from(self)

        if reciprocal is True:
            for u in self._node:
                for v in self._node:
                    if u >= v:
                        try:
                            outc = self._succ[u][v]['t']
                            intc = self._pred[u][v]['t']
                            for o in outc:
                                r = set(range(o[0], o[1]+1))
                                for i in intc:
                                    r2 = set(range(i[0], i[1]+1))
                                    inter = list(r & r2)
                                    if len(inter) == 1:
                                        H.add_interaction(u, v, t=inter[0])
                                    elif len(inter) > 1:
                                        H.add_interaction(u, v, t=inter[0], e=inter[-1])

                        except:
                            pass

        else:
            for it in self.interactions_iter():
                for t in it[2]['t']:
                    H.add_interaction(it[0], it[1], t=t[0], e=t[1])

        H.graph = deepcopy(self.graph)
        H._node = deepcopy(self._node)
        return H