If the node is an embedded view, traverses up the view tree to return the closest
ancestor view that is attached to a component. If it's already a component node,
returns itself.
359577
function getClosestComponentAncestor(node) {
    while (node.tNode.type === 2 /* View */) {
        node = node.view[HOST_NODE];
    }
    return node;
}
362071
def findViewsWithAttribute(self, attr, val, root="ROOT"):
        '''
        

        '''

        return self.__findViewsWithAttributeInTree(attr, val, root)
715998
def _traverse_parent(node, objtypes):
    
    curr_node = node.parent
    while curr_node is not None:
        if isinstance(curr_node, objtypes):
            return curr_node
        curr_node = curr_node.parent
    return None
932193
private View findStartView(RecyclerView.LayoutManager layoutManager,
                               OrientationHelper helper) {

        if (layoutManager instanceof LinearLayoutManager) {
            int firstChild = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();

            if (firstChild == RecyclerView.NO_POSITION) {
                return null;
            }

            View child = layoutManager.findViewByPosition(firstChild);

            float visibleWidth;

            // We should return the child if it's visible width
            // is greater than 0.5 of it's total width.
            // In a RTL configuration, we need to check the start point and in LTR the end point
            if (isRtlHorizontal) {
                visibleWidth = (float) (helper.getTotalSpace() - helper.getDecoratedStart(child))
                        / helper.getDecoratedMeasurement(child);
            } else {
                visibleWidth = (float) helper.getDecoratedEnd(child)
                        / helper.getDecoratedMeasurement(child);
            }

            // If we're at the end of the list, we shouldn't snap
            // to avoid having the last item not completely visible.
            boolean endOfList = ((LinearLayoutManager) layoutManager)
                    .findLastCompletelyVisibleItemPosition()
                    == layoutManager.getItemCount() - 1;

            if (visibleWidth > 0.5f && !endOfList) {
                return child;
            } else if (endOfList) {
                return null;
            } else {
                // If the child wasn't returned, we need to return
                // the next view close to the start.
                return layoutManager.findViewByPosition(firstChild + 1);
            }
        }

        return null;
    }
784828
def default_root
      # child WindowLayout classes can return *their* NSView subclass from self.nsview_class
      view_class = self.class.targets || NSWindow
      view_class.alloc.initWithContentRect([[0, 0], [0, 0]],
        styleMask: NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask,
        backing: NSBackingStoreBuffered,
        defer: false)
    end
944427
function findPrevRowNode(node){
	var i, last, prev,
		parent = node.parent,
		siblings = parent ? parent.children : null;

	if(siblings && siblings.length > 1 && siblings[0] !== node){
		// use the lowest descendant of the preceeding sibling
		i = $.inArray(node, siblings);
		prev = siblings[i - 1];
		_assert(prev.tr);
		// descend to lowest child (with a <tr> tag)
		while(prev.children){
			last = prev.children[prev.children.length - 1];
			if(!last.tr){
				break;
			}
			prev = last;
		}
	}else{
		// if there is no preceding sibling, use the direct parent
		prev = parent;
	}
	return prev;
}
1217067
protected final Segment getSegment( NodeCache cache,
                                        CachedNode parent ) {
        if (parent != null) {
            ChildReference ref = parent.getChildReferences(cache).getChild(key);
            if (ref == null) {
                // This node doesn't exist in the parent
                throw new NodeNotFoundInParentException(key, parent.getKey());
            }
            return ref.getSegment();
        }
        // This is the root node ...
        return workspace(cache).childReferenceForRoot().getSegment();
    }
542202
def is_descendant_of(self, node):
        
        return self.pk in [obj.pk for obj in node.get_descendants()]
1173928
function initNodePath(node, view) {
  var path = [];
  while (node !== view) {
    var parent = node.parentNode;
    path.unshift(indexOf.call(parent.childNodes, node));
    node = parent;
  }
  return path;
}
616983
function ( el, selector, rootEl ) {
            var root = rootEl || document,
                parent = el.parentNode;
    
            if ( parent && parent != root ) {
                var match = this.match( parent, selector );
                return match? parent : this.closest( parent, selector );
            } else {
                return;
            }
        }
600866
function closest (el, selector, scope) {
  scope = scope || document.documentElement

  // walk up the dom
  while (el && el !== scope) {
    if (matches(el, selector)) return el
    el = el.parentNode
  }

  // check scope for match
  return matches(el, selector) ? el : null
}
15431
private View getFirstViewUnobscuredByHeader(RecyclerView parent, View firstHeader) {
        boolean isReverseLayout = mOrientationProvider.isReverseLayout(parent);
        int step = isReverseLayout ? -1 : 1;
        int from = isReverseLayout ? parent.getChildCount() - 1 : 0;
        for (int i = from; i >= 0 && i <= parent.getChildCount() - 1; i += step) {
            View child = parent.getChildAt(i);
            if (!itemIsObscuredByHeader(parent, child, firstHeader, mOrientationProvider.getOrientation(parent))) {
                return child;
            }
        }
        return null;
    }
824832
function findRootContainerNode(inst) {
  // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  // traversal, but caching is difficult to do correctly without using a
  // mutation observer to listen for all DOM changes.
  if (typeof inst.tag === 'number') {
    while (inst['return']) {
      inst = inst['return'];
    }
    if (inst.tag !== HostRoot) {
      // This can happen if we're in a detached tree.
      return null;
    }
    return inst.stateNode.containerInfo;
  } else {
    while (inst._hostParent) {
      inst = inst._hostParent;
    }
    var rootNode = ReactDOMComponentTree_1.getNodeFromInstance(inst);
    return rootNode.parentNode;
  }
}
521135
public Node previousNode() {

		if (currentNode == null)
			return null;

		// get sibling
		Node result = getPreviousSibling(currentNode);
		if (result == null) {
			result = getParentNode(currentNode);
			if (result != null) {
				currentNode = result;
				return result;
			}
			return null;
		}

		// get the lastChild of result.
		Node lastChild = getLastChild(result);

		Node prev = lastChild;
		while (lastChild != null) {
			prev = lastChild;
			lastChild = getLastChild(prev);
		}

		lastChild = prev;

		// if there is a lastChild which passes filters return it.
		if (lastChild != null) {
			currentNode = lastChild;
			return lastChild;
		}

		// otherwise return the previous sibling.
		currentNode = result;
		return result;
	}
706926
function isAncestor(ancestor, descendant) {
	return ancestor
		&& descendant
		&& Boolean(ancestor.compareDocumentPosition(descendant) & Node.DOCUMENT_POSITION_CONTAINED_BY);
}
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;
  }
180196
function attachEmbeddedView(parentView, elementData, viewIndex, view) {
    var embeddedViews = elementData.viewContainer._embeddedViews;
    if (viewIndex === null || viewIndex === undefined) {
        viewIndex = embeddedViews.length;
    }
    view.viewContainerParent = parentView;
    addToArray(embeddedViews, viewIndex, view);
    attachProjectedView(elementData, view);
    Services.dirtyParentQueries(view);
    var prevView = viewIndex > 0 ? embeddedViews[viewIndex - 1] : null;
    renderAttachEmbeddedView(elementData, prevView, view);
}