def is_duplicate_or_self_connection(self, target_node: PeerInfo) -> bool:
    if (is_localhost(target_node.host) and (target_node.port == self._port)):
        self.log.debug(f'Not connecting to {target_node}')
        return True
    for connection in self.all_connections.values():
        if ((connection.host == target_node.host) and (connection.peer_server_port == target_node.port)):
            self.log.debug(f'Not connecting to {target_node}, duplicate connection')
            return True
    return False
def is_duplicate_or_self_connection(self, target_node: PeerInfo) -> bool:
    if (is_localhost(target_node.host) and (target_node.port == self._port)):
        self.log.debug(f'Not connecting to {target_node}')
        return True
    for connection in self.all_connections.values():
        if ((connection.host == target_node.host) and (connection.peer_server_port == target_node.port)):
            self.log.debug(f'Not connecting to {target_node}, duplicate connection')
            return True
    return False