def METHOD_NAME():
    orders = Order.query.all()
    for order in orders:
        payments = OnlinePayment.query.filter(OnlinePayment.order == order).all()
        if len(payments) > 1:
            dupes = []
            for payment in payments:
                if not payment.transactions:
                    dupes.append(payment)
            for dupe in dupes:
                db.session.delete(dupe)
    db.session.commit()