<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def process_patches(self, pset, stmt, elem, altname=None):
 """Process patches for data node `name` from `pset`. `stmt` provides the context in YANG and `elem` is the parent element in the output schema. Refinements adding documentation and changing the config status are immediately applied. The returned tuple consists of: - a dictionary of refinements, in which keys are the keywords of the refinement statements and values are the new values of refined parameters. - a list of 'augment' statements that are to be applied directly under `elem`. - a new patch set containing patches applicable to substatements of `stmt`. """

        if altname:
            name = altname
        else:
            name = stmt.arg
        new_pset = {}
        augments = []
        refine_dict = dict.fromkeys(("presence", "default", "mandatory",
                                     "min-elements", "max-elements"))
        for p in pset.pop(self.add_prefix(name, stmt), []):
            if p.path:
                head = p.pop()
                if head in new_pset:
                    new_pset[head].append(p)
                else:
                    new_pset[head] = [p]
            else:
                for refaug in p.plist:
                    if refaug.keyword == "augment":
                        augments.append(refaug)
                    else:
                        for s in refaug.substmts:
                            if s.keyword == "description":
                                self.description_stmt(s, elem, None)
                            elif s.keyword == "reference":
                                self.reference_stmt(s, elem, None)
                            elif s.keyword == "must":
                                self.must_stmt(s, elem, None)
                            elif s.keyword == "config":
                                self.nma_attribute(s, elem)
                            elif refine_dict.get(s.keyword, False) is None:
                                refine_dict[s.keyword] = s.arg
        return (refine_dict, augments, new_pset)