<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add(self, method_mask, path, func):
 """ Add a function to the middleware chain. This function is returned when iterating over the chain with matching method and path. Args: method_mask (growler.http.HTTPMethod):
 A bitwise mask intended to match specific request methods. path (str or regex):
 An object with which to compare request urls func (callable):
 The function to be yieled from the generator upon a request matching the method_mask and path """

        is_err = len(signature(func).parameters) == 3
        is_subchain = isinstance(func, MiddlewareChain)
        tup = MiddlewareNode(func=func,
                             mask=method_mask,
                             path=path,
                             is_errorhandler=is_err,
                             is_subchain=is_subchain,)
        self.mw_list.append(tup)