I implemented avl tree and works correctly, if keys are different or duplicates are not so much. When i try to insert or delete 10000 times random keys in range [0;5] in some moment tree becomes not avl. Is there any reason that rotations broke avl tree constraints if keys duplicates?