<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_parent_of_type(typ, obj):
 """ Finds first object up the parent chain of the given type. If no parent of the given type exists None is returned. Args: typ(str or python class):
 The type of the model object we are looking for. obj (model object):
 Python model object which is the start of the search process. """

    if type(typ) is not text:
        typ = typ.__name__

    while hasattr(obj, 'parent'):
        obj = obj.parent
        if obj.__class__.__name__ == typ:
            return obj