When I initially read this function, I thought the only purpose it served was to detect dependencies. I see now that it actually returns the entire list of dependencies that need to be loaded, while checking for circular dependencies is just a side effect of the function. Can you name this function something else, like get_dependency_call_list(app) to get the call list of dependencies, and just state in the comments that it will throw an error if there is a circular dependency?