/** * @param namedElement named element * @return ancestors of the named element, beginning with the root namespace and ending with the * named element itself, skipping local scopes */ public static Iterable<? extends INamedElement> ancestors(final INamedElement namedElement) { final Deque<INamedElement> ancestors = new LinkedList<>(); INamedElement ancestor = namedElement; while (membership(ancestor) != ScopeMembership.Root) { ancestors.addFirst(ancestor); ancestor = parentNamedElementOfScope(ancestor.parent()); } ancestors.addFirst(ancestor); return ancestors; }