The list of ancestors is very long.
 Trim it down to just the length of the class we are looking for.

 Takes an optional block method to transform the result
 with a map operation
7970
def ancestors_until(until_class)
        # trim down the list
        ancestors_list = all_ancestors[0..all_ancestors.index(until_class)]

        # map to the fully qualified class name
        ancestors_list.map { |klass| yield(klass) }
      end
489408
public void trimToSize()
    {
        if (elements.length != size && elements.length > INITIAL_CAPACITY)
        {
            elements = Arrays.copyOf(elements, Math.max(INITIAL_CAPACITY, size));
        }
    }
610314
def _ancestors(
            self, qname: Union[QualName, bool] = None) -> List[InstanceNode]:
        """"""
        return self.up()._ancestors(qname)
940039
def ancestors
      node  = self
      nodes = []
      nodes << node = node.parent while node.parent
      nodes
    end
629176
def ancestor_slugs
      return [] if !Config.get(:url_nesting) || parent.nil? || parent.root?
      visible_ancestors.map(&:slug).compact
    end
596075
def get_ancestors(self):
        ""

        if self._ancestors:
            return self._ancestors

        if not self.parent:
            return []

        obj = self.resource_map.get(self.parent.uid)

        while obj and obj.member_name:
            self._ancestors.append(obj)
            obj = obj.parent

        self._ancestors.reverse()
        return self._ancestors
1279515
function (nodeA, nodeB) {
            var ancestors = listAncestor(nodeA);
            for (var n = nodeB; n; n = n.parentNode) {
                if ($.inArray(n, ancestors) > -1) { return n; }
            }
            return null; // difference document area
        }
425367
def deepest_common_ancestor(goterms, godag):
    '''
        
    '''
    # Take the element at maximum depth.
    return max(common_parent_go_ids(goterms, godag), key=lambda t: godag[t].depth)
952946
def ancestors(self):
        
        ancestors = []
        node = self.ancestor
        while node is not None:
            ancestors.append(node)
            node = node.ancestor
        return ancestors
401074
protected List<String> trim(List<String> list) {
        if (list == null || list.size() == 0)
            return list;

        List<String> result = new ArrayList<String>();
        for (String s : list) {
            s = trim(s);

            if (s == null || s.length() == 0)
                continue;

            result.add(s);
        }

        return result;
    }
148943
def ancestors(self):
    
    ret = []
    workunit = self
    while workunit is not None:
      ret.append(workunit)
      workunit = workunit.parent
    return ret
676665
def ancestors
        a = Array.new
        self.parent._ancestors(a) unless self.parent.nil?
        return a
    end
227945
def ancestors
      return to_enum(__callee__) unless block_given?
      node = self
      loop do
        node = node.parent
        yield node
      end
    end
1229850
def lineage(self):
        
        if not self.parent:
            return [self]
        else:
            L = self.parent.lineage()
            L.append(self)
            return L
1078084
def ancestors(self, recurs=True, context=None):
        
        # FIXME: should be possible to choose the resolution order
        # FIXME: inference make infinite loops possible here
        yielded = {self}
        if context is None:
            context = contextmod.InferenceContext()
        if not self.bases and self.qname() != "builtins.object":
            yield builtin_lookup("object")[1][0]
            return

        for stmt in self.bases:
            with context.restore_path():
                try:
                    for baseobj in stmt.infer(context):
                        if not isinstance(baseobj, ClassDef):
                            if isinstance(baseobj, bases.Instance):
                                baseobj = baseobj._proxied
                            else:
                                continue
                        if not baseobj.hide:
                            if baseobj in yielded:
                                continue
                            yielded.add(baseobj)
                            yield baseobj
                        if not recurs:
                            continue
                        for grandpa in baseobj.ancestors(recurs=True, context=context):
                            if grandpa is self:
                                # This class is the ancestor of itself.
                                break
                            if grandpa in yielded:
                                continue
                            yielded.add(grandpa)
                            yield grandpa
                except exceptions.InferenceError:
                    continue
787073
public void trimToSize() {
    for (Collection<V> collection : backingMap().values()) {
      ArrayList<V> arrayList = (ArrayList<V>) collection;
      arrayList.trimToSize();
    }
  }
544125
public void trim() {
    keys = Arrays.copyOf(keys, size);
    values = Arrays.copyOf(values, size);
    for (MappeableContainer c : values) {
      c.trim();
    }
  }