def _finish_filter(self, lst, key, include_self, exclusive, biggest_first):
key = self._actual_key(key)<EOL>locations = [x[<NUM_LIT:0>] for x in lst]<EOL>if not include_self and key in locations:<EOL><INDENT>lst.pop(locations.index(key))<EOL><DEDENT>lst.sort(key=lambda x: x[<NUM_LIT:1>], reverse=biggest_first)<EOL>lst = [x for x, y in lst]<EOL>if key == '<STR_LIT>' and '<STR_LIT>' not in self and exclusive:<EOL><INDENT>return ['<STR_LIT>'] if '<STR_LIT>' in lst else []<EOL><DEDENT>elif exclusive:<EOL><INDENT>removed, remaining = set(), []<EOL>while lst:<EOL><INDENT>current = lst.pop(<NUM_LIT:0>)<EOL>faces = self[current]<EOL>if not faces.intersection(removed):<EOL><INDENT>removed.update(faces)<EOL>remaining.append(current)<EOL><DEDENT><DEDENT>lst = remaining<EOL><DEDENT>if '<STR_LIT>' not in self and '<STR_LIT>' in lst:<EOL><INDENT>lst[-<NUM_LIT:1> if biggest_first else <NUM_LIT:0>] = lst.pop(lst.index('<STR_LIT>'))<EOL><DEDENT>return lst<EOL>
Finish filtering a GIS operation. Can optionally exclude the input key, sort results, and exclude overlapping results. Internal function, not normally called directly.