[common] cleanup avl and related code

First effort towards #666
This function should have not be used and can be removed.