TODO: Set<String> ancestorRevIDs as additional parameter
421642
@Override
    public List<RevisionInternal> getRevisionHistory(RevisionInternal rev) {
        Document doc = getDocument(rev.getDocID());
        if (doc == null)
            return null;
        try {
            try {
                if (!doc.selectRevID(rev.getRevID(), false))
                    return null;
            } catch (ForestException e) {
                Log.e(TAG, "Error in getRevisionHistory() rev=" + rev, e);
                return null;
            }
            List<RevisionInternal> history = new ArrayList<RevisionInternal>();
            do {
                RevisionInternal ancestor = ForestBridge.revisionObject(
                        doc, rev.getDocID(), null, false);
                if (ancestor == null)
                    break;
                ancestor.setMissing(!doc.hasRevisionBody());
                history.add(ancestor);
                // TODO: implement once ancestorRevIDs param is given.
                //if(ancestorRevIDs!=null&&ancestorRevIDs.contains(ancestor.getRevID()))
                //    break;
            } while (doc.selectParentRev());
            return history;
        } finally {
            doc.free();
        }
    }
1370429
function buildErrMsg(ancestor, msg) {
	var args = Array.prototype.slice.call(arguments);
	args.shift();

	if (ancestor) {
		args[0] += '. Requested from [%s] file';
		args.push(ancestor);
	}

	return util.format.apply(util, args);
}
74791
private static AncestorListener createAncestorListener(JComponent component, final WindowListener windowListener) {
        final WeakReference<JComponent> weakReference = new WeakReference<JComponent>(component);

        return new AncestorListener() {
            public void ancestorAdded(AncestorEvent event) {
                // TODO if the WeakReference's object is null, remove the
                // WeakReference as an AncestorListener.
                Window window = weakReference.get() == null ? null : SwingUtilities.getWindowAncestor(weakReference.get());

                if (window != null) {
                    window.removeWindowListener(windowListener);
                    window.addWindowListener(windowListener);
                }
            }

            public void ancestorRemoved(AncestorEvent event) {
                Window window = weakReference.get() == null ? null : SwingUtilities.getWindowAncestor(weakReference.get());

                if (window != null) {
                    window.removeWindowListener(windowListener);
                }
            }

            public void ancestorMoved(AncestorEvent event) {
                // no implementation.
            }
        };
    }
1103365
function _normalizePath(path, parent, ancestors) {
    if (path === '/') {
        return path;
    }

    path = path.replace(/\/$/, '');

    // If path begins with / then assume it is independent route
    if (path[0] === '/') {
        return path;
    }

    // If no parent, and route doesn't start with /, then prepend /
    if (! parent) {
        return `/${path}`;
    }

    if (ancestors) {
        return _cleanPath(`${ancestors.join('/')}/${path}`);
    }

    return _cleanPath(`${parent.path}/${path}`);
}
216712
def get_ancestors(self, include_self=False, depth=None):
        """"""
        if self.is_root_node():
            if not include_self:
                return self._toplevel().objects.none()
            else:
                # Filter on pk for efficiency.
                return self._toplevel().objects.filter(pk=self.pk)

        params = {"%s__child" % self._closure_parentref():self.pk}
        if depth is not None:
            params["%s__depth__lte" % self._closure_parentref()] = depth
        ancestors = self._toplevel().objects.filter(**params)
        if not include_self:
            ancestors = ancestors.exclude(pk=self.pk)
        return ancestors.order_by("%s__depth" % self._closure_parentref())
1223353
function replaceNode(ancestors, node) {
  const ancestor = ancestors[ancestors.length - 1];

  if (typeof ancestor.index === "number") {
    ancestor.node[ancestor.key][ancestor.index] = node;
  } else {
    ancestor.node[ancestor.key] = node;
  }
}
861813
@Override
    public boolean hasAncestor(QueryNode descendantNode, QueryNode ancestorNode) {
        return getAncestors(descendantNode).contains(ancestorNode);
    }
574545
public void setAncestorToSave(QPath newAncestorToSave)
   {
      if (!ancestorToSave.equals(newAncestorToSave))
      {
         isNeedReloadAncestorToSave = true;
      }
      this.ancestorToSave = newAncestorToSave;
   }
1179493
@GET
    @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
    @Path("/{gavc}" + ServerAPI.GET_ANCESTORS)
    public Response getAncestors(@PathParam("gavc") final String gavc, @Context final UriInfo uriInfo){
        if(LOG.isInfoEnabled()) {
            LOG.info(String.format("Got a get artifact request [%s]", gavc));
        }

        final FiltersHolder filters = new FiltersHolder();
        filters.getDecorator().setShowLicenses(false);
        filters.init(uriInfo.getQueryParameters());

        final AncestorsView view = new AncestorsView("Ancestor List Of " + gavc,
                filters.getDecorator(),
                getLicenseHandler(),
                getModelMapper());

        final List<DbModule> dbAncestors = getArtifactHandler().getAncestors(gavc, filters);
        final Artifact artifact = DataUtils.createArtifact(gavc);

        for(final DbModule dbAncestor : dbAncestors){
            final Module ancestor = getModelMapper().getModule(dbAncestor);
            view.addAncestor(ancestor, artifact);
        }

        return Response.ok(view).build();
    }
532109
function is_ancestor(node, target)
{
    while (target.parentNode) {
        target = target.parentNode;
        if (node == target)
            return true;
    }
    return false;
}
565371
@Override
    public int doEndTag() throws JspException {

        Tag t = findAncestorWithClass(this, I_CmsJspTagParamParent.class);
        if (t == null) {
            throw new JspTagException(Messages.get().getBundle(pageContext.getRequest().getLocale()).key(
                Messages.ERR_PARENTLESS_TAG_1,
                new Object[] {"param"}));
        }
        // take no action for null or empty names
        if (CmsStringUtil.isEmpty(m_name)) {
            return EVAL_PAGE;
        }

        // send the parameter to the appropriate ancestor
        I_CmsJspTagParamParent parent = (I_CmsJspTagParamParent)t;
        String value = m_value;
        if (value == null) {
            if ((bodyContent == null) || (bodyContent.getString() == null)) {
                value = "";
            } else {
                value = bodyContent.getString().trim();
            }
        }
        if (m_encode) {
            parent.addParameter(
                CmsEncoder.encode(m_name, OpenCms.getSystemInfo().getDefaultEncoding()),
                CmsEncoder.encode(value, OpenCms.getSystemInfo().getDefaultEncoding()));
        } else {
            parent.addParameter(m_name, value);
        }

        return EVAL_PAGE;
    }
1149095
def get_ancestor(ancestor_type)
      ancestor = self.parent_element
      target_type = {:directory => Directory,
                     :feature_file => FeatureFile,
                     :feature => Feature,
                     :test => TestElement,
                     :step => Step,
                     :table => Table,
                     :example => Example
      }[ancestor_type]

      raise(ArgumentError, "Unknown ancestor type '#{ancestor_type}'.") if target_type.nil?

      until ancestor.is_a?(target_type) || ancestor.nil?
        ancestor = ancestor.parent_element
      end

      ancestor
    end
1069509
@Restricted(NoExternalUse.class)
    public static @Nonnull <T> T getNearestAncestorOfTypeOrThrow(@Nonnull StaplerRequest request, @Nonnull Class<T> clazz) {
        T t = request.findAncestorObject(clazz);
        if (t == null) {
            throw new IllegalArgumentException("No ancestor of type " + clazz.getName() + " in the request");
        }
        return t;
    }
2240
private static List<Column> getAncestorColumns(Resource currentResource, Resource rootResource) {
    List<Column> columns = new ArrayList<>();
    List<Resource> ancestors = getAncestors(currentResource, rootResource);
    for (int i = 0; i < ancestors.size(); i++) {
      Resource r = ancestors.get(i);

      String activeId;
      if (i < ancestors.size() - 1) {
        activeId = ancestors.get(i + 1).getPath();
      }
      else {
        activeId = currentResource.getPath();
      }

      Column column = new Column()
          .columnId(r.getPath())
          .lazy(true)
          .activeId(activeId);
      columns.add(column);
    }
    return columns;
  }
1289744
function lastAncestor(node, pred) {
  const ancestors = listAncestor(node);
  return lists.last(ancestors.filter(pred));
}
931979
@Override
    public List<? extends Tree> getAncestors() {
        if ( getParent()==null ) return null;
        List<Tree> ancestors = new ArrayList<Tree>();
        Tree t = this;
        t = t.getParent();
        while ( t!=null ) {
            ancestors.add(0, t); // insert at start
            t = t.getParent();
        }
        return ancestors;
    }
675407
function ancestorMatch(el, tokens, dividedTokens, root) {
      var cand
      // recursively work backwards through the tokens and up the dom, covering all options
      function crawl(e, i, p) {
        while (p = walker[dividedTokens[i]](p, e)) {
          if (isNode(p) && (found = interpret.apply(p, q(tokens[i])))) {
            if (i) {
              if (cand = crawl(p, i - 1, p)) return cand
            } else return p
          }
        }
      }
      return (cand = crawl(el, tokens.length - 1, el)) && (!root || isAncestor(cand, root))
    }