Reimplement avl_add

This PR contains a complete reimplementation of `avl_add()` (which was not yet renamed to `avl_insert()`)