|
@ -18,13 +18,17 @@ def safe_pred(node): |
|
|
except ObjectDoesNotExist: |
|
|
except ObjectDoesNotExist: |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
def first_brother(node): |
|
|
|
|
|
brother = node |
|
|
|
|
|
while safe_pred(brother) is not None: |
|
|
|
|
|
brother = safe_pred(brother) |
|
|
|
|
|
return brother |
|
|
|
|
|
|
|
|
# A to samé pro .father_of_first |
|
|
# A to samé pro .father_of_first |
|
|
def safe_father_of_first(node): |
|
|
def safe_father_of_first(node): |
|
|
first_brother = node |
|
|
first = first_brother(node) |
|
|
while safe_pred(first_brother) is not None: |
|
|
|
|
|
first_brother = safe_pred(first_brother) |
|
|
|
|
|
try: |
|
|
try: |
|
|
return first_brother.father_of_first |
|
|
return first.father_of_first |
|
|
except ObjectDoesNotExist: |
|
|
except ObjectDoesNotExist: |
|
|
return None |
|
|
return None |
|
|
|
|
|
|
|
|