I have implemented a baseline avoidance system which basically mimics the human operator rules of reducing altitude and returning to land or landing the vehicle in this pull request:
This is enough to fulfil requirements from most regulators. IMHO doing anything more fancy than that requires vehicle-to-vehicle coordination and essentially TCAS compliance. I carefully avoided trying to solve the much bigger problem of traffic coordination. The goal of this PR is to make the operation safer, not create something that potentially leads to unintended manoeuvres due to an automatic avoidance action.
I would be interested in general feedback and thoughts before this goes into master.