Internal function. Return the parent Node, from the input node after
applying filter, whatToshow. The current node is not consulted or set.
13340
private Node getParentNode(Node node) {

		if (node == null || node == root)
			return null;

		Node newNode = node.getParentNode();
		if (newNode == null)
			return null;

		int accept = acceptNode(newNode);

		if (accept == NodeFilter.FILTER_ACCEPT)
			return newNode;
		else
			// if (accept == NodeFilter.SKIP_NODE)
			// and REJECT too.
			return getParentNode(newNode);

	}
1297962
def _get_node_parent(self, age, pos):
        
        return self.nodes[age][int(pos / self.comp)]
1263665
function () {
            if (this.parent() !== null) {
                var self = this;
                this.parent().children(_cs.filter(this.parent().children(), function (x) {
                    return x !== self;
                }));
                this.parent(null);
            }
        }
443909
def find(node):
    
    if node.parent is None:
        return node
    root = node
    while root.parent is not None:
        root = root.parent
    parent = node
    while parent.parent is not root:
        grandparent = parent.parent
        parent.parent = root
        parent = grandparent
    return root
94400
function TreeWalker(root, whatToShow, filter) {
  if (!root || !root.nodeType) {
    utils.NotSupportedError();
  }

  // Read-only properties
  this._root = root;
  this._whatToShow = Number(whatToShow) || 0;
  this._filter = filter || null;
  this._active = false;
  // Read-write property
  this._currentNode = root;
}
581731
function(filter){
      filter = filter || this.filter;

      var cursor = this.cursor_;
      var prevSibling = this.c; // previous sibling
      var prevChild = this.d;   // previous child

      do
      {
        var node = cursor ? cursor[prevSibling] : this.root_[prevChild];
        if (node)
        {
          while (node[prevChild])
            node = node[prevChild];
          cursor = node;
        }
        else
          if (cursor)
            cursor = cursor[PARENT_NODE];

        if (!cursor || cursor === this.root_)
        {
          cursor = null;
          break;
        }
      }
      while (!filter(cursor));

      return this.cursor_ = cursor;
    }
551373
function getParentNode(node) {
        var parent = node.parentNode;

        if (parent && parent.nodeType == 11 && parent.host) {
            // If the parent is a shadow root, return the host element.
            return parent.host;
        }
        return parent;
    }
952272
def set_parent(self, node):
        
        self._parent = node

        if node is None:
            # detach from parent
            self._depth = 0
        else:
            self._depth = node.get_depth() + 1
755829
def _get_parent(root):
    

    elem = root

    while True:
        elem = elem.getparent()

        if elem.tag in ['ul', 'ol']:
            return elem
670945
private Node getPreviousSibling(Node node) {

		if (node == null || node == root)
			return null;

		Node newNode = node.getPreviousSibling();
		if (newNode == null) {
			newNode = node.getParentNode();
			if (newNode == null || node == root)
				return null;
			int parentAccept = acceptNode(newNode);
			if (parentAccept == NodeFilter.FILTER_SKIP)
				return getPreviousSibling(newNode);

			return null;
		}

		int accept = acceptNode(newNode);

		if (accept == NodeFilter.FILTER_ACCEPT)
			return newNode;
		else if (accept == NodeFilter.FILTER_SKIP) {
			Node fChild = getLastChild(newNode);
			if (fChild == null)
				return getPreviousSibling(newNode);

			return fChild;
		} else
			// if (accept == NodeFilter.REJECT_NODE)
			return getPreviousSibling(newNode);

	}
483308
function _findNearestDOMParent(element, parentNodeName) {
			while (element.nodeName !== parentNodeName) {
				if (element.nodeName === "CONTROL-TREE") {
					break;
				}
				element = element.parentNode;
			}

			return element;
		}
735365
def node_after(node)
      node.parent.equal? self or
        raise ArgumentError, "node is not a child"
      fields = self.fields
      i = node.instance_variable_get(:@parent_field).index + 1
      (i...fields.length).each do |i|
        f = fields[i]
        if f.child? && (val = self.send(f.reader))
          return val
        end
      end
      return nil
    end
241012
def filter(parent, indent)
      return unless (filter_name = accept :filter)

      # Get element attributes
      atts = attributes(shorthand_attributes) || {}

      # Accept inline text or multiline text feed as first child
      error :fiter unless accept(:line_feed).strip.empty?

      # Get everything under the filter and set it as the node value
      # and create a new node and set its extension
      parent[@children] << [
        :filter,
        filter_name[1..-1].to_sym,
        atts,
        get_indented_lines(indent),
        indent
      ]
    end
937509
function (node) { // returns right (remaining) subtree
            if (!node || (node.parentNode === this)) {
                return node }
            else {
                return this.splitSubtreeBefore (
                                    !node.previousSibling // if first node in parent, nothing to split – simply proceed to parent
                                        ? node.parentNode
                                        : document.createElement  (node.parentNode.tagName)
                                                  .copyAttributes (node.parentNode)
                                                  .insertMeBefore (node.parentNode)
                                                  .appendChildren (node.prevSiblings)
                                                  .nextSibling) } }
1341546
private Node getFirstChild(Node node) {

		if (node == null)
			return null;

		Node newNode = node.getFirstChild();
		if (newNode == null)
			return null;

		int accept = acceptNode(newNode);
		if (accept == NodeFilter.FILTER_ACCEPT)
			return newNode;
		else if (accept == NodeFilter.FILTER_SKIP && newNode.hasChildNodes())
			return getFirstChild(newNode);

		// if (accept == NodeFilter.REJECT_NODE)
		return getNextSibling(newNode);
	}
688672
def get_parent(self, update=False):
        """"""
        if self._meta.proxy_for_model:
            # the current node is a proxy model; the returned parent
            # should be the same proxy model, so we need to explicitly
            # fetch it as an instance of that model rather than simply
            # following the 'parent' relation
            if self.parent_id is None:
                return None
            else:
                return self.__class__.objects.get(pk=self.parent_id)
        else:
            return self.parent
71499
def get_parent(self):
        
        if not self.parent:
            parent = self._safe_get_element('ParentASIN')
            if parent:
                self.parent = self.api.lookup(ItemId=parent)
        return self.parent