<p>Gets the path from this element's parent to a root, i.e. its ancestors in the tree.</p>

@return the list of ancestors with this element's parent in position 0 or an empty list if this element is a root.
971214
public final List<T> getAncestors() {
      List<T> path = new ArrayList<>();
      HierarchicalEnumValue<T> hev = Cast.as(this);
      do {
         hev = Cast.as(hev.getParent());
         if (hev != null && hev != getSingleRoot()) {
            path.add(Cast.as(hev));
         }
      } while (hev != null && hev != getSingleRoot());
      return path;
   }
624161
public Node root() {
        Node node = this;
        while (node.parentNode != null)
            node = node.parentNode;
        return node;
    }
1197383
@Override
    public Path getParent() {
        final List<String> tokens = tokenize(this);
        // No parent?
        final int numTokens = tokens.size();
        if (numTokens == 0 || (numTokens == 1 && !this.isAbsolute())) {
            return null;
        }

        // Iterate over all but the last token and build a new path
        final StringBuffer sb = new StringBuffer();
        if (this.isAbsolute()) {
            sb.append(ArchivePath.SEPARATOR);
        }
        for (int i = 0; i < numTokens - 1; i++) {
            if (i >= 1) {
                sb.append(ArchivePath.SEPARATOR);
            }
            sb.append(tokens.get(i));
        }

        final String parentPath = sb.toString();
        return new ShrinkWrapPath(parentPath, fileSystem);
    }
947541
public @Nonnull Object getRoot() {
    Chain current = this;
    while (current.hasParent()) {
      current = current.getParent();
    }
    return current.getValue();
  }
916660
public HelpTopicNode getPreviousSibling() {
        int i = getIndex() - 1;
        return i < 0 ? null : parent.children.get(i);
    }
1374264
protected static List<Point> getNodePath (Node n)
    {
        Node cur = n;
        ArrayList<Point> path = Lists.newArrayList();

        while (cur != null) {
            // add to the head of the list since we're traversing from
            // the end to the beginning
            path.add(0, new Point(cur.x, cur.y));

            // advance to the next node in the path
            cur = cur.parent;
        }

        return path;
    }
1071029
public Node previousSibling() {
        if (parentNode == null)
            return null; // root

        if (siblingIndex > 0)
            return parentNode.ensureChildNodes().get(siblingIndex-1);
        else
            return null;
    }
699585
def ancestors(self):
        
        ancestors = []
        p = self.parent
        while p is not None:
            ancestors.append(p)
            p = p.parent
        return ancestors
390719
public static Path getRootPath(Path path) {
    if (path.isRoot()) {
      return path;
    }
    return getRootPath(path.getParent());
  }
1143876
@Override
  public IndexTreePath<E> next() {
    Iterator<IndexTreePath<E>> enumeration = queue.peek();
    IndexTreePath<E> nextPath = enumeration.next();

    Iterator<IndexTreePath<E>> children;
    if(nextPath.getEntry() instanceof LeafEntry) {
      children = EMPTY_ENUMERATION;
    }
    else {
      N node = index.getNode(nextPath.getEntry());
      children = node.children(nextPath);
    }

    if(!enumeration.hasNext()) {
      queue.remove();
    }
    if(children.hasNext()) {
      queue.offer(children);
    }
    return nextPath;
  }
352426
public Tree getPreviousSibling() {
		if (parent != null && key != null) {
			if (key instanceof Integer) {
				int idx = (int) key;
				if (idx < 1) {
					return null;
				}
				return parent.get(idx - 1);
			}
			Tree previous = null;
			for (Tree child : parent) {
				if (key.equals(child.key)) {
					return previous;
				}
				previous = child;
			}
		}
		return null;
	}
1293595
def get_ancestors(self):
        
        ancestors = list(self.get_parents())
        ancestor_unique_attributes = set([(a.__class__, a.id) for a in ancestors])
        ancestors_with_parents = [a for a in ancestors if isinstance(a, DescendantMixin)]
        for ancestor in ancestors_with_parents:
            for parent in ancestor.get_ancestors():
                if (parent.__class__, parent.id) not in ancestor_unique_attributes:
                    ancestors.append(parent)
        return ancestors
501130
@Pure
	public List<S> getPath() {
		if (this.path == null) {
			return Collections.emptyList();
		}
		return Collections.unmodifiableList(this.path);
	}
596783
def _get_ancestors_of(self, obs_nodes_list):
        
        if not obs_nodes_list:
            return set()
        return set(obs_nodes_list) | set(self.parent_node)
996645
@Override
  public Key getParent() {
    List<PathElement> ancestors = getAncestors();
    if (ancestors.isEmpty()) {
      return null;
    }
    PathElement parent = ancestors.get(ancestors.size() - 1);
    Key.Builder keyBuilder;
    if (parent.hasName()) {
      keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getName());
    } else {
      keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getId());
    }
    String namespace = getNamespace();
    if (namespace != null) {
      keyBuilder.setNamespace(namespace);
    }
    return keyBuilder.addAncestors(ancestors.subList(0, ancestors.size() - 1)).build();
  }
270708
public static List<Path> getAncestorPathList(Path startPath) {
		List<Path> ancestorPathList = new ArrayList<>();
		buildPathListOfAncestorDirectory(ancestorPathList, startPath);
		Collections.reverse(ancestorPathList);
		return ancestorPathList;
	}
1180876
public static List<Node> getSiblings(Node parent, Node element) {
		List<Node> result = new ArrayList<>();
		NodeList list = parent.getChildNodes();

		for (int i = 0; i < list.getLength(); i++) {
			Node el = list.item(i);

			if (el.getNodeName().equals(element.getNodeName())) {
				result.add(el);
			}
		}

		return result;
	}