Fix infinite looping when searching self