async def METHOD_NAME(
    nodes: list[Node], ec2_instances: list[EC2InstanceData]
) -> tuple[list[AssociatedInstance], list[EC2InstanceData]]:
    """returns the associated and non-associated instances"""
    associated_instances: list[AssociatedInstance] = []
    non_associated_instances: list[EC2InstanceData] = []
    def _find_node_with_name(node: Node) -> bool:
        assert node.Description  # nosec
        return bool(node.Description.Hostname == docker_node_name)
    for instance_data in ec2_instances:
        try:
            docker_node_name = node_host_name_from_ec2_private_dns(instance_data)
        except Ec2InvalidDnsNameError:
            logger.exception("Unexcepted EC2 private dns name")
            non_associated_instances.append(instance_data)
            continue
        if node := next(iter(filter(_find_node_with_name, nodes)), None):
            associated_instances.append(AssociatedInstance(node, instance_data))
        else:
            non_associated_instances.append(instance_data)
    return associated_instances, non_associated_instances