<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_parents(self, uri, type='all'):
 """Return parents of a given entry. Parameters uri : str The URI of the entry whose parents are to be returned. See the get_uri method to construct this URI from a name space and id. type : str 'all': return all parents irrespective of level; 'immediate': return only the immediate parents; 'top': return only the highest level parents """

        # First do a quick dict lookup to see if there are any parents
        all_parents = set(self.isa_or_partof_closure.get(uri, []))
        # If there are no parents or we are looking for all, we can return here
        if not all_parents or type == 'all':
            return all_parents

        # If we need immediate parents, we search again, this time knowing that
        # the uri is definitely in the graph since it has some parents
        if type == 'immediate':
            node = rdflib.term.URIRef(uri)
            immediate_parents = list(set(self.isa_or_partof_objects(node)))
            return [p.toPython() for p in immediate_parents]
        elif type == 'top':
            top_parents = [p for p in all_parents if
                           not self.isa_or_partof_closure.get(p)]
            return top_parents