Add attributes to avl functions

This PR redoes #140
This function includes a `NULL`-check.