def get_final_trans_petri_given_fmarking(final_marking):
    """
    Deduce the end activities given the final marking of the Petri net

    Parameters
    -----------
    final_marking
        Final marking of the Petri net

    Returns
    -----------
    final_trans
        List of final transitions deduced from the Petri net
    """
    final_trans = []
    final_involved_places = set()
    final_involved_arcs = set()
    final_involved_trans = set()
    for place in final_marking:
        final_involved_places.add(place)
        for arc in place.in_arcs:
            final_involved_arcs.add(arc)
            trans = arc.source
            final_involved_trans.add(trans)
            if trans.label is not None:
                if trans not in final_trans:
                    final_trans.append(trans)
    if len(final_trans) == 0 or True:
        for place in final_marking:
            for arc in place.in_arcs:
                trans = arc.source
                for arc2 in trans.in_arcs:
                    final_involved_arcs.add(arc2)
                    place2 = arc2.source
                    final_involved_places.add(place2)
                    for arc3 in place2.in_arcs:
                        final_involved_arcs.add(arc3)
                        trans2 = arc3.source
                        final_involved_trans.add(trans2)
                        if trans2.label is not None:
                            if trans not in final_trans:
                                final_trans.append(trans2)
    return (final_trans, final_involved_places, final_involved_arcs,
        final_involved_trans)
