Again, aiming toward a point where we can Cythonize more of the loader, make more of it iterative.
Changes proposed in this merge request:
loader.py: Make _sort_dependencies() a static iterative method
loader.py: Make _collect_element() iterative