<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getparent(d, pth):
 """Get the parent node of a subdict as specified by the key path in `pth`. Parameters d : dict Dict tree in which access is required pth : str or tuple of str Dict key """


        c = d
        for key in pth[:-1]:
            if not isinstance(c, dict):
                raise InvalidValueError(c)
            elif key not in c:
                raise UnknownKeyError(pth)
            else:
                c = c.__getitem__(key)
        return c