<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check(self, key, value):
 """Check whether key,value pair is allowed. The key is allowed if there is a corresponding key in the defaults class attribute dict. The value is not allowed if it is a dict in the defaults dict and not a dict in value. Parameters key : str or tuple of str Dict key value : any Dict value corresponding to key """


        # This test necessary to avoid unpickling errors in Python 3
        if hasattr(self, 'dflt'):
            # Get corresponding node to self, as determined by pth
            # attribute, of the defaults dict tree
            a = self.__class__.getnode(self.dflt, self.pth)
            # Raise UnknownKeyError exception if key not in corresponding
            # node of defaults tree
            if key not in a:
                raise UnknownKeyError(self.pth + (key,))
                # Raise InvalidValueError if the key value in the defaults
                # tree is a dict and the value parameter is not a dict and
            elif isinstance(a[key], dict) and not isinstance(value, dict):
                raise InvalidValueError(self.pth + (key,))