Gets the root node of this tree.
@param node The TreeElement to start from
@return The root node
517633
public static TreeElement getRoot(TreeElement node)
    {
        TreeElement parentNode = node.getParent();
        while (parentNode != null) {
            node = parentNode;
            parentNode = node.getParent();
        }
        return node;
    }
1091268
protected Node removeNode( Node node )
    {
        // Remove node.
        node.previous.next = node.next;
        node.next.previous = node.previous;
        node.removed = true;
        return node;
    }
896131
public int getEndPosition(Tree node) {
    JCCompilationUnit compilationUnit = (JCCompilationUnit) getPath().getCompilationUnit();
    if (compilationUnit.endPositions == null) {
      return -1;
    }
    return ((JCTree) node).getEndPosition(compilationUnit.endPositions);
  }
214601
@Nullable
  public static Element getFirstChildElement (@Nullable final Node aStartNode)
  {
    if (aStartNode == null)
      return null;
    return NodeListIterator.createChildNodeIterator (aStartNode)
                           .findFirstMapped (filterNodeIsElement (), x -> (Element) x);
  }
1177220
@Pure
	public static Rectangle2d getNodeBuildingBounds(AbstractGISTreeSetNode<?, ?> node) {
		assert node != null;
		final double w = node.nodeWidth / 2.;
		final double h = node.nodeHeight / 2.;
		final IcosepQuadTreeZone zone = node.getZone();
		final double lx;
		final double ly;
		if (zone == null) {
			// Is root node
			lx = node.verticalSplit - w;
			ly = node.horizontalSplit - h;
		} else {
			switch (zone) {
			case SOUTH_EAST:
				lx = node.verticalSplit;
				ly = node.horizontalSplit - h;
				break;
			case SOUTH_WEST:
				lx = node.verticalSplit - w;
				ly = node.horizontalSplit - h;
				break;
			case NORTH_EAST:
				lx = node.verticalSplit;
				ly = node.horizontalSplit;
				break;
			case NORTH_WEST:
				lx = node.verticalSplit - w;
				ly = node.horizontalSplit;
				break;
			case ICOSEP:
				return getNodeBuildingBounds(node.getParentNode());
			default:
				throw new IllegalStateException();
			}
		}
		return new Rectangle2d(lx, ly, node.nodeWidth, node.nodeHeight);
	}
1353509
public Node<T> get(T element) {
		for (Node<T> node : nodes)
			if (node.element.equals(element))
				return node;
		return null;
	}
498924
@NonNull static <E> Node<E> findLast(@NonNull Node<E> node) {
    Node<E> next;
    while ((next = node.getNextRelaxed()) != null) {
      node = next;
    }
    return node;
  }
1004800
public static <T extends TreeNode<T>> T getRoot(T node) {
        if (node == null) return null;
        if (node.getParent() != null) return getRoot(node.getParent());
        return node;
    }
194623
protected void createRootNode() {
		final Node<K, V> node = createLeafNode();
		node.allocId();
		rootIdx = node.id;
		height = 1;
		elements = 0;
		putNode(node);
	}
1290244
protected String getNodeName(Node node) {
        String result = node.getLocalName();
        return result == null ? node.getNodeName() : result;
    }
391319
private Node getNode(boolean bDataRoot)
    {
        if (m_data == null)
        {
            DocumentBuilder db = Util.getDocumentBuilder();
            synchronized (db)
            {
                m_data = (Node)db.newDocument();
                String rootTag = ROOT_TAG;
                if (this.getMessageDataDesc(null) != null)
                	if (this.getMessageDataDesc(null).getKey() != null)
                		rootTag = this.getMessageDataDesc(null).getKey();
                ((Document)m_data).appendChild(((Document)m_data).createElement(rootTag));
            }
        }
        if (bDataRoot)
        	if (m_data instanceof Document)
        		return ((Document)m_data).getDocumentElement();
        return (Node)m_data;
    }
1330557
public Node getScopeRoot() {
    int roots = scopeRoots.size();
    if (roots > 0) {
      return scopeRoots.get(roots - 1);
    } else {
      AbstractScope<?, ?> s = scopes.peek();
      return s != null ? s.getRootNode() : null;
    }
  }
1071302
public TreeElement findNode(String nodeName)
    {
        TreeElement root = getRoot(this);
        return root.findNodeRecurse(nodeName, nodeName);
    }
763702
private ViewNode getRootViewNode(HttpServletRequest request) throws Exception {
    String rooNodeID = getRootNodeID(request);
    if (rooNodeID == null){
      Debug.logError("[JdonFramework] root Id is null ! " , module);
      return null;
    }
    Debug.logVerbose("[JdonFramework] get the tree's root Node: " + rooNodeID, module);
    ViewNode rNode = new ViewNode(rooNodeID, rooNodeID, true);
    rNode.setRoot(true);
    return rNode;
  }
79010
public static Optional<Node> getContainingNode(final Node node) {
        try {
            if (node.getDepth() == 0) {
                return empty();
            }

            // check ancestors recursively only either of the following two cases applies:
            // 1. the PARENT is a FEDORA_PAIRTREE
            // 2. the PARENT is FEDORA_NON_RDF_SOURCE_DESCRIPTION
            final Node parent = node.getParent();
            if (parent.isNodeType(FEDORA_PAIRTREE) || parent.isNodeType(FEDORA_NON_RDF_SOURCE_DESCRIPTION)) {
                return getContainingNode(parent);
            }
            return Optional.of(parent);
        } catch (final RepositoryException ex) {
            throw new RepositoryRuntimeException(ex);
        }
    }
418136
private TreeNode getParentTreeNode(TreeNode child) {
        TreeNode parentTreeNode = parentIndex.get(child);

        if (parentTreeNode == null)
            return null;

        // Makes sure the parent node is still present in the tree
        else if (contains(parentTreeNode.getQueryNode()))
            return parentTreeNode;
        else
            throw new RuntimeException("Internal error: points to a parent that is not (anymore) in the tree");
    }
1240056
public Node parentNode() {

		if (currentNode == null)
			return null;

		Node node = getParentNode(currentNode);

		if (node != null)
			currentNode = node;

		return node;

	}