Return the first object in the parent tree of class `cls`.
(element: Element, cls: Type)
| 398 | |
| 399 | |
| 400 | def get_obj_in_upper_tree(element: Element, cls: Type) -> Element: |
| 401 | """Return the first object in the parent tree of class `cls`.""" |
| 402 | parent = element._parent |
| 403 | if parent is None: |
| 404 | raise ValueError(f"The top of the tree was reached without finding a {cls}") |
| 405 | if not isinstance(parent, cls): |
| 406 | return get_obj_in_upper_tree(parent, cls) |
| 407 | return parent |
| 408 | |
| 409 | |
| 410 | def parse_options(**kwargs: TypeJsonValue) -> Dict[str, TypeJsonValueNoNone]: |
no outgoing calls