Simple way to list order of referential integrity in Postgres
You can "dive" into the system tables and get all the tables that reference a specific table (and all those that reference them, etc). It will be a recursive query, not very difficult to write.

However, for the simple operation you want to to perform, there is a simple solution:
TRUNCATE with the magic option CASCADE:

truncate table a cascade ;


Tested at rextester.com