def all_edges(G, nbunch=None, data=False):
    """
    Get a list of all (both incoming and outgoing) edges of (Multi)DiGraph G
    :param G: (Multi)DiGraph
    :param nbunch: list of nodes whose adjacent edges we want to find
    :param data: boolean: return list with or without nodes data
    :return: corresponding list of all (both incoming and outgoing) edges (no duplicates in list)
    """
    if data:
        result = [(e[0], e[1], e[2]['stmt']) for e in G.in_edges(nbunch=nbunch, data=data)]
        result += [(e[0], e[1], e[2]['stmt']) for e in G.out_edges(nbunch=nbunch, data=data)]
        return list(set(result))
    else:  # data == False
        result = list(G.in_edges(nbunch=nbunch, data=data))
        result += list(G.out_edges(nbunch=nbunch, data=data))
        ret = list(set(result))
    return ret