def get_most_complete_pm(pms):
    """ Return plugin match with longer version, if not available
        will return plugin match with ``presence=True``
    """
    if not pms:
        return None
    selected_version = None
    selected_presence = None
    for pm in pms:
        if pm.version:
            if not selected_version:
                selected_version = pm
            elif len(pm.version) > len(selected_version.version):
                selected_version = pm
        elif pm.presence:
            selected_presence = pm
    return selected_version or selected_presence
