<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def match_lb_nodes(self, lb_id, existing_nodes, host_addresses, host_port):
 """ Add and remove nodes to match the host addresses and port given, based on existing_nodes. HPCS doesn't allow a load balancer with no backends, so we'll add first, delete after. :param string lb_id: Load balancer id :param :class:`list` of :class:`dict` existing_nodes: Existing nodes :param :class:`list` host_addresses: Node host addresses :param string port: Node port """

        delete_filter = lambda n: \
                n['address'] not in host_addresses or \
                str(n['port']) != str(host_port)

        delete_nodes = filter(delete_filter, existing_nodes)
        delete_node_ids = [n['id'] for n in delete_nodes]
        delete_node_hosts = [n['address'] for n in delete_nodes]
        
        current_nodes = set([n['address'] for n in existing_nodes])
        current_nodes -= set(delete_node_hosts)
        add_nodes = host_addresses - current_nodes
        
        if add_nodes:
            nodes_to_add = [
                    {'address': n, 'port': str(host_port)}
                    for n in add_nodes
            ]
            args = (lb_id, nodes_to_add)
            self.add_lb_nodes(*args)

        if delete_node_ids:
            args = (lb_id, delete_node_ids)
            self.remove_lb_nodes(*args)
        
        log.info("Were %d nodes. Added %d nodes; deleted %d nodes" % 
                (len(existing_nodes), len(add_nodes), len(delete_nodes)))