def find_server(dbinstance, params):
    """
    Find an existing service binding matching the given parameters.
    """

    lookup_params = params.copy()

    for srv in dbinstance.servers:
        # Populating srv_params must be in sync with what lookup_target()
        # returns
        srv_params = {}
        for attr in ("host", "cluster", "service_address",
                     "address_assignment", "alias"):
            value = getattr(srv, attr, None)
            if value:
                srv_params[attr] = value

        if lookup_params == srv_params:
            return srv

    return None