<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_deleted_nodes(self):
 """ delete imported nodes that are not present in the old database """

        imported_nodes = Node.objects.filter(data__contains=['imported'])
        deleted_nodes = []

        for node in imported_nodes:
            if OldNode.objects.filter(pk=node.pk).count() == 0:
                user = node.user
                deleted_nodes.append(node)
                node.delete()
                # delete user if there are no other nodes assigned to her
                if user.node_set.count() == 0:
                    user.delete()

        if len(deleted_nodes) > 0:
            self.message('deleted %d imported nodes from local DB' % len(deleted_nodes))
        self.deleted_nodes = deleted_nodes