def delete_nodes(pks_to_delete):
    """
    Delete a set of nodes. (From AiiDA cockbook)
    Note: TODO this has to be improved for workchain removal. (checkpoints and co)
    Also you will be backchecked.

    BE VERY CAREFUL!

    .. note::

        The script will also delete
        all children calculations generated from the specified nodes.

    :params pks_to_delete: a list of the PKs of the nodes to delete
    """
    from django.db import transaction
    from django.db.models import Q
    from aiida.backends.djsite.db import models
    all_pks_to_delete = set(pks_to_delete)
    for pk in pks_to_delete:
        all_pks_to_delete.update(models.DbNode.objects.filter(
            input_links__in=pks_to_delete).values_list('pk', flat=True))
    print(
        'I am going to delete {} nodes, including ALL THE CHILDRENof the nodes you specified. Do you want to continue? [y/N]'
        .format(len(all_pks_to_delete)))
    answer = input()
    if answer.strip().lower() == 'y':
        with transaction.atomic():
            models.DbLink.objects.filter(Q(input__in=all_pks_to_delete) | Q
                (output__in=all_pks_to_delete)).delete()
            models.DbNode.objects.filter(pk__in=all_pks_to_delete).delete()
