'Adds ancestor of requested feature for each level to supplied dict.
If the caller already has the location row, including path and
parent fields, they can supply it via feature to avoid a db lookup.
If a dict is not supplied in results, one is created. The results
dict is returned in either case.
If ids=True and names=False (used by old S3LocationSelectorWidget):
For each ancestor, an entry  is added to results, like
ancestor.level : ancestor.id
If ids=False and names=True (used by address_onvalidation):
For each ancestor, an entry  is added to results, like
ancestor.level : ancestor.name
If ids=True and names=True (used by new S3LocationSelectorWidget):
For each ancestor, an entry  is added to results, like
ancestor.level : {name : ancestor.name, id: ancestor.id}'

def get_parent_per_level(self, results, feature_id, feature=None, ids=True, names=True):

    if (not results):
        results = {}
    _id = feature_id
    if ((not feature_id) and (not feature)):
        return results
    if ((not feature_id) and ('path' not in feature) and ('parent' in feature)):
        feature = self._lookup_parent_path(feature.parent)
        _id = feature.id
    elif ((not feature) or ('path' not in feature) or ('parent' not in feature)):
        feature = self._lookup_parent_path(feature_id)
    if (feature and (feature.path or feature.parent)):
        if feature.path:
            path = feature.path
        else:
            path = self.update_location_tree(feature)
        if feature.parent:
            strict = self.get_strict_hierarchy(feature.parent)
        else:
            strict = self.get_strict_hierarchy(_id)
        if (path and strict and (not names)):
            path_ids = map(int, path.split('/'))
            for (i, _id) in enumerate(path_ids[:(-1)]):
                results[('L%i' % i)] = _id
        elif path:
            ancestors = self.get_parents(_id, feature=feature)
            if ancestors:
                for ancestor in ancestors:
                    if (ancestor.level and (ancestor.level in self.hierarchy_level_keys)):
                        if (names and ids):
                            results[ancestor.level] = Storage()
                            results[ancestor.level].name = ancestor.name
                            results[ancestor.level].id = ancestor.id
                        elif names:
                            results[ancestor.level] = ancestor.name
                        else:
                            results[ancestor.level] = ancestor.id
        if (not feature_id):
            results[feature.level] = feature.name
        if names:
            hierarchy_level_keys = self.hierarchy_level_keys
            for key in hierarchy_level_keys:
                if (not results.has_key(key)):
                    results[key] = None
    return results
