def _cmp_by_local_origin(path1, path2):
    """Select locally originating path as best path.

    Locally originating routes are network routes, redistributed routes,
    or aggregated routes. For now we are going to prefer routes received
    through a Flexinet-Peer as locally originating route compared to routes
    received from a BGP peer.
    Returns None if given paths have same source.
    """
    # If both paths are from same sources we cannot compare them here.
    if path1.source == path2.source:
        return None

    # Here we consider prefix from NC as locally originating static route.
    # Hence it is preferred.
    if path1.source is None:
        return path1

    if path2.source is None:
        return path2

    return None
Select locally originating path as best path.

    Locally originating routes are network routes, redistributed routes,
    or aggregated routes. For now we are going to prefer routes received
    through a Flexinet-Peer as locally originating route compared to routes
    received from a BGP peer.
    Returns None if given paths have same source.