Type Instability in performance critical function

It was there, hidden in the “> Code”. Please check if it is correct. I think it is.

One note: for small array sizes this function is faster than the builtin indexin. But it is slower for larger arrays. Also the builtin returns nothing for elements not found, while this one simply does not push the element into the array.