def get_obj_in_upper_tree(element, cls):
if not hasattr(element, '<STR_LIT>'):<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>.format(cls))<EOL><DEDENT>parent = element._parent<EOL>if not isinstance(parent, cls):<EOL><INDENT>return get_obj_in_upper_tree(parent, cls)<EOL><DEDENT>return parent<EOL>
Return the first object in the parent tree of class `cls`.