Return the child of `ancestor` that contains `descendant`.
(ancestor: Node, descendant: LN)
| 483 | |
| 484 | |
| 485 | def child_towards(ancestor: Node, descendant: LN) -> LN | None: |
| 486 | """Return the child of `ancestor` that contains `descendant`.""" |
| 487 | node: LN | None = descendant |
| 488 | while node and node.parent != ancestor: |
| 489 | node = node.parent |
| 490 | return node |
| 491 | |
| 492 | |
| 493 | def replace_child(old_child: LN, new_child: LN) -> None: |
no outgoing calls
no test coverage detected