def findElementRecursively(obj, elem_name):
    """Recursively find hierarchy of element in nested object"""
    if not hasattr(obj, "__dict__"):  # object has no named fields
        return None
    elif elem_name in obj.__dict__.keys():  # required hierarchy was reached
        return obj
    else:  # hierarchy is yet to be found
        for key in obj.__dict__.keys():
            if key.endswith("_"):
                continue
            hierarchy = findElementRecursively(obj.__getattribute__(key), elem_name)
            if hierarchy is not None:
                return hierarchy
    return None