libnm-util: refactor hash_to_connection()