SmartRTL
This is a sample Python app that shows a graph-based smart return-to-home function. This allows a drone to automatically return home along the shortest path of points it's already traveled over (and are thus known as good and free of obstructions).
It's designed to work in the Pythonista IDE on iOS
Draw a path with as many loops or squiggles as you want, press the "RTL" button, and it will find the shortest path home along known-good points.