I have the same problem.
I want to update user when user already exists, but fetch all user using moodle_user_get_users_by_id and then check the response for searched user is non optimal.
How can we check if user exists knowing only email and username ?
David