<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_elem(elem_ref, default=None):
 """ Gets the element referenced by elem_ref or returns the elem_ref directly if its not a reference. :param elem_ref: :param default: :return: """

    if not is_elem_ref(elem_ref):
        return elem_ref
    elif elem_ref[0] == ElemRefObj:
        return getattr(elem_ref[1], elem_ref[2], default)
    elif elem_ref[0] == ElemRefArr:
        return elem_ref[1][elem_ref[2]]