find the first common ancestor
(cls, node1, node2)
| 99 | |
| 100 | @classmethod |
| 101 | def find_ancestor_intersection(cls, node1, node2): |
| 102 | ''' |
| 103 | find the first common ancestor |
| 104 | ''' |
| 105 | if node1 == None or node2 == None: |
| 106 | return None |
| 107 | if node1 == node2: |
| 108 | return node1 |
| 109 | length1 = node1.get_depth() |
| 110 | length2 = node2.get_depth() |
| 111 | if length1 > length2: |
| 112 | return tree_node.find_ancestor_intersection(node1.father,node2) |
| 113 | else: |
| 114 | return tree_node.find_ancestor_intersection(node1, node2.father) |
| 115 | |
| 116 | |
| 117 |
no test coverage detected