You can't access sets like that. I could do list(node_ids)[0] but I think this is cleaner. I added a comment.