Factor out "first non-null string" search.