def _edge_func(G):
    """Returns the edges from G, handling keys for multigraphs as necessary.

    """
    if G.is_multigraph():

        def get_edges(nbunch=None):
            return G.edges(nbunch, keys=True)

    else:

        def get_edges(nbunch=None):
            return G.edges(nbunch)

    return get_edges