Returns the current/latest learned path.

    Checks if given paths are from same source/peer and then compares their
    version number to determine which path is received later. If paths are from
    different source/peer return None.

def _compare_by_version(path1, path2):
    """Returns the current/latest learned path.

    Checks if given paths are from same source/peer and then compares their
    version number to determine which path is received later. If paths are from
    different source/peer return None.
    """
    if path1.source == path2.source:
        if path1.source_version_num > path2.source_version_num:
            return path1
        else:
            return path2
    return None