Removes the document tree preceding the given element. If include_element
    is True, the given element is kept in the tree, otherwise it is removed.
329875
def trim_tree_before(element, include_element=True, keep_head=True):
    
    el = element
    for parent_el in element.iterancestors():
        parent_el.text = None
        if el != element or include_element:
            el = el.getprevious()
        else:
            parent_el.text = el.tail
        while el is not None:
            remove_el = el
            el = el.getprevious()
            tag = remove_el.tag
            is_head = isinstance(tag, string_class) and tag.lower() == 'head'
            if not keep_head or not is_head:
                parent_el.remove(remove_el)
        el = parent_el
164799
function () {
		var element = this.element,
			childNodes = element.childNodes,
			i = childNodes.length,
			node;

		while (i--) {
			node = childNodes[i];
			node.parentNode.removeChild(node);
		}
	}
355911
protected void replaceWithChildren(Element element)
    {
        Element parent = (Element) element.getParentNode();
        while (element.getFirstChild() != null) {
            parent.insertBefore(element.removeChild(element.getFirstChild()), element);
        }
        parent.removeChild(element);
    }
1091268
protected Node removeNode( Node node )
    {
        // Remove node.
        node.previous.next = node.next;
        node.next.previous = node.previous;
        node.removed = true;
        return node;
    }
34089
function() {
		var ns = this.tree._ns;
		this.element.unbind(ns);
		this.tree.$container.unbind(ns);
		$(document).unbind(ns);
	}
1082669
public void removeChild(TreeElement child)
    {

        if (child == null || _children == null)
            return;

        int size = _children.size();
        int removeIndex = -1;
        for (int i = 0; i < size; i++) {
            if (child == (TreeElement) _children.get(i)) {
                _children.remove(i);
                child.setParent(null);
                removeIndex = i;
                break;
            }
        }
        if (removeIndex >= 0) {
            size = _children.size();
            for (int i = removeIndex; i < size; i++) {
                TreeElement thisChild = (TreeElement) _children.get(i);
                thisChild.updateName(this, i);
            }
        }
    }
1122570
function() {
				var ns = this.tree._ns;
				this.element.off(ns);
				this.tree.$container.off(ns);
				$(document).off(ns);
			}
1369756
public void removeDatum (Object element)
    {
        int dex = _data.indexOf(element);
        if (dex != -1) {
            removeDatum(dex);
        }
    }
466333
def delete_element(self, element):
        
        if element not in self.element_finder:
            raise ValueError("No such element in the priority queue.")
        entry = self.element_finder[element]
        entry[1] = self.INVALID
693115
def forget_tree(element_id, view)
      removed = forget_view(element_id, view)
      if view.subviews
        view.subviews.each do | sub |
          if (sub_ids = sub.motion_kit_meta[:motion_kit_ids])
            sub_ids.each do | sub_id |
              forget_tree(sub_id, sub) || []
            end
          end
        end
      end
      removed
    end
750543
def cleanup_nodes(doc):
    
    for node in doc.documentElement.childNodes:
        if node.nodeType == Node.TEXT_NODE and node.nodeValue.isspace():
            doc.documentElement.removeChild(node)
    return doc
713905
private int removeOrRetain(Collection<?> collection, boolean retain, int from, int to) {
        for (int i = from; i < to; i++) {
            if (collection.contains(elements[i]) == retain) {
                continue;
            }

            /*
             * We've encountered an element that must be removed! Create a new
             * array and copy in the surviving elements one by one.
             */
            Object[] newElements = new Object[elements.length - 1];
            System.arraycopy(elements, 0, newElements, 0, i);
            int newSize = i;
            for (int j = i + 1; j < to; j++) {
                if (collection.contains(elements[j]) == retain) {
                    newElements[newSize++] = elements[j];
                }
            }

            /*
             * Copy the elements after 'to'. This is only useful for sub lists,
             * where 'to' will be less than elements.length.
             */
            System.arraycopy(elements, to, newElements, newSize, elements.length - to);
            newSize += (elements.length - to);

            if (newSize < newElements.length) {
                newElements = Arrays.copyOfRange(newElements, 0, newSize); // trim to size
            }
            int removed = elements.length - newElements.length;
            elements = newElements;
            return removed;
        }

        // we made it all the way through the loop without making any changes
        return 0;
    }
365393
public void remove( Element<T> element ) {
		if( element.next == null ) {
			last = element.previous;
		} else {
			element.next.previous = element.previous;
		}
		if( element.previous == null ) {
			first = element.next;
		} else {
			element.previous.next = element.next;
		}
		size--;
		element.clear();
		available.push(element);
	}
981156
public void removeElementsThatAreUnreachableFrom(Element element) {
        if (element != null) {
            Set<Element> elementsToShow = new HashSet<>();
            Set<Element> elementsVisited = new HashSet<>();
            findElementsToShow(element, element, elementsToShow, elementsVisited);

            for (ElementView elementView : getElements()) {
                if (!elementsToShow.contains(elementView.getElement()) && canBeRemoved(elementView.getElement())) {
                    removeElement(elementView.getElement());
                }
            }
        }
    }
475352
void removeElement(int element_handle) {
		if (m_b_store_duplicates)
			throw new GeometryException("invalid call");

		int quad_handle = get_quad_(element_handle);
		disconnect_element_handle_(element_handle);
		free_element_and_box_node_(element_handle);

		int q = quad_handle;

		while (q != -1) {
			set_sub_tree_element_count_(q, get_sub_tree_element_count_(q) - 1);
			int parent = get_parent_(q);

			if (get_sub_tree_element_count_(q) == 0) {
				assert (get_local_element_count_(q) == 0);

				if (q != m_root) {
					int quadrant = get_quadrant_(q);
					m_quad_tree_nodes.deleteElement(q);
					set_child_(parent, quadrant, -1);
				}
			}

			q = parent;
		}
	}
768063
public void removeElement(CmsContainerPageElementPanel elementWidget) {

        if (elementWidget.getInheritanceInfo().isNew()) {
            getHandler().removeElement(elementWidget, ElementRemoveMode.saveAndCheckReferences);
        } else {
            elementWidget.getInheritanceInfo().setVisible(false);
            elementWidget.addStyleName(HIDDEN_ELEMENT_CLASS);
            Element elementOverlay = DOM.createDiv();
            elementOverlay.setClassName(HIDDEN_ELEMENT_OVERLAY_CLASS);
            elementWidget.getElement().appendChild(elementOverlay);
            getGroupContainerWidget().add(elementWidget);
            updateButtonVisibility(elementWidget);
            m_showElementsButton.enable();
            getGroupContainerWidget().refreshHighlighting();
        }
        m_changedInheritanceInfo = true;
    }
898148
function(element) {
        element = OpenLayers.Util.getElement(element);
        element.parentNode.removeChild(element);
    }