From ab69ca3fe2936532c80e51ad734d3f72039a1700 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Wed, 18 Mar 2020 21:56:25 +0100 Subject: [PATCH] Fix safe_father_of_first --- seminar/treelib.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/seminar/treelib.py b/seminar/treelib.py index cfb49d86..def0f6da 100644 --- a/seminar/treelib.py +++ b/seminar/treelib.py @@ -20,7 +20,11 @@ def safe_pred(node): # A to samé pro .father_of_first def safe_father_of_first(node): - return node.prev + first_brother = node + while safe_pred(first_brother) is not None: + first_brother = safe_pred(first_brother) + try: + return first_brother.father_of_first except ObjectDoesNotExist: return None