Make pattern-tree tips point to same object if they are equal.
(self, uniq=None)
| 43 | return self |
| 44 | |
| 45 | def fix_identities(self, uniq=None): |
| 46 | """Make pattern-tree tips point to same object if they are equal.""" |
| 47 | if not hasattr(self, 'children'): |
| 48 | return self |
| 49 | uniq = list(set(self.flat())) if uniq is None else uniq |
| 50 | for i, c in enumerate(self.children): |
| 51 | if not hasattr(c, 'children'): |
| 52 | assert c in uniq |
| 53 | self.children[i] = uniq[uniq.index(c)] |
| 54 | else: |
| 55 | c.fix_identities(uniq) |
| 56 | |
| 57 | def fix_repeating_arguments(self): |
| 58 | """Fix elements that should accumulate/increment values.""" |