How to delete fields in mongodb except last ones

I have a mongo database in which i need to delete all the fields except the last one
the location of fields are :- Hello - collections - rules - flow - action, and inside the action there are many fields and i need to delete all of them except the last one
Can anyone tell me the script to delete in python

Have you got an example document?