Get a list of gnucash accounts in python

For use in scripts it might be helpful to get a flat list of accounts from a given gnucash file. Fortunately gnucash has an extensive python binding. See the script gnucash_accounts.py for an example on how to use it:

$ ./gnucash_accounts.py gnucash.gnucash 
Aktiva:Barvermögen:Bargeld
Aktiva:Barvermögen:Girokonto
Aktiva:Barvermögen:Sparkonto
[...]