Searches inside the children of "root" for a component that's a JPanel. Then inside the JPanel it
looks for the target. If the target is inside the JPanel the JPanel is removed from root.
494386
protected static void removeChildInsidePanel( JComponent root , JComponent target ) {
		int N = root.getComponentCount();

		for (int i = 0; i < N; i++) {
			try {
				JPanel p = (JPanel)root.getComponent(i);
				Component[] children = p.getComponents();
				for (int j = 0; j < children.length; j++) {
					if( children[j] == target ) {
						root.remove(i);
						return;
					}
				}
			}catch( ClassCastException ignore){}
		}
	}
616490
public static Component findParentForm(final Component childComponent)
	{
		final Component parent = findParent(childComponent, Form.class);
		if ((parent != null) && parent.getClass().equals(Form.class))
		{
			return parent;
		}
		return null;
	}
519102
@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean sel, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {

		super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
		
		SiteNode node = null;
		Target target = null;
		if (value instanceof SiteNode) {
			node = (SiteNode) value;
			if (node.getUserObject() instanceof Target) {
				target = (Target) node.getUserObject();
			}
		}
		
		if (node != null) {
			if (node.isRoot()) {
				setIcon(DisplayUtils.getScaledIcon(ROOT_ICON));
			} else if (target != null) {
				if (target.getContext() != null) {
					if (target.getContext().isInScope()) {
						setIcon(DisplayUtils.getScaledIcon(CONTEXT_IN_SCOPE_ICON));
					} else {
						setIcon(DisplayUtils.getScaledIcon(CONTEXT_ICON));
					}
				} else if (target.isInScopeOnly()) {
					setIcon(DisplayUtils.getScaledIcon(ALL_IN_SCOPE_ICON));
				}
			}
		}

		return this;
	}
439327
public void setRootComponent(Component component) throws IllegalRootComponentException {
        if (component != null && component.getParent() != null) {
            throw new IllegalRootComponentException("A component with parent cannot be set as a graph's root component. Make sure the component doesn't parent.");
        }
        this.rootComponent = component;
    }
1144539
@Override
    public ComponentType detach() {
        synchronized (this) {
            if (parent != null) {
                ComponentVertex oldParent = parent;
                synchronized (tree) {
                    if (!tree.isStarted()) {
                        throw new IllegalStateException(
                            "Components may not be detached from a tree before"
                                + " a Start event has been fired on it.");
                    }
                    synchronized (oldParent) {
                        parent.children.remove(this);
                        parent.tree.clearHandlerCache();
                        parent = null;
                    }
                    ComponentTree newTree = new ComponentTree(this);
                    newTree.setEventPipeline(new FeedBackPipelineFilter(
                        new EventProcessor(newTree)));
                    setTree(newTree);
                }
                Detached evt = new Detached(component(), oldParent.component());
                oldParent.fire(evt);
                evt = new Detached(component(), oldParent.component());
                fire(evt);
            }
            return component();
        }
    }
297301
private synchronized Renderer findRenderer(final WComponent component,
			final Duplet<String, Class<?>> key) {
		LOG.info("Looking for layout for " + key.getSecond().getName() + " in " + key.getFirst());

		Renderer renderer = findConfiguredRenderer(component, key.getFirst());

		if (renderer == null) {
			renderers.put(key, NULL_RENDERER);
		} else {
			renderers.put(key, renderer);
		}

		return renderer;
	}
1011690
public static Component getRootParent(Component component)
	{
		while (null != component.getParent())
		{
			component = component.getParent();
		}
		return component;
	}
1003246
public void setControlledPanel (final JComponent panel)
    {
        panel.addHierarchyListener(new HierarchyListener() {
            public void hierarchyChanged (HierarchyEvent e) {
                boolean nowShowing = panel.isDisplayable();
                //System.err.println("Controller." + Controller.this +
                //    "  nowShowing=" + nowShowing +
                //    ", wasShowing=" + _showing);
                if (_showing != nowShowing) {
                    _showing = nowShowing;
                    if (_showing) {
                        wasAdded();
                    } else {
                        wasRemoved();
                    }
                }
            }

            boolean _showing = false;
        });
    }
142289
int getIndexOfChild(final WComponent childComponent) {
		ComponentModel model = getComponentModel();
		List<WComponent> children = model.getChildren();

		return children == null ? -1 : children.indexOf(childComponent);
	}
206527
private void removeResource(FacesContext context, UIComponent resource, UIViewRoot view) {
        view.removeComponentResource(context, resource, HEAD);
        view.removeComponentResource(context, resource, TARGET);
    }
988510
@Deprecated
    public static void finalizeForDeletion(UIComponent component)
    {
        // remove any existing marks of deletion
        component.getAttributes().remove(MARK_DELETED);

        // finally remove any children marked as deleted
        if (component.getChildCount() > 0)
        {
            for (Iterator<UIComponent> iter = component.getChildren().iterator(); iter.hasNext();)
            {
                UIComponent child = iter.next();
                if (child.getAttributes().containsKey(MARK_DELETED))
                {
                    iter.remove();
                }
            }
        }

        // remove any facets marked as deleted
        if (component.getFacetCount() > 0)
        {
            Map<String, UIComponent> facets = component.getFacets();
            Collection<UIComponent> col = facets.values();
            for (Iterator<UIComponent> itr = col.iterator(); itr.hasNext();)
            {
                UIComponent fc = itr.next();
                if (fc.getAttributes().containsKey(MARK_DELETED))
                {
                    itr.remove();
                }
            }
        }
    }
819476
def removeComponent(self, component):
        
        if isinstance(component, int):
            index = component
        else:
            index = self._getComponentIndex(component)
        index = normalizers.normalizeIndex(index)
        if index >= self._len__components():
            raise ValueError("No component located at index %d." % index)
        self._removeComponent(index)
830210
protected void destroyOldEngineComponent(ComponentList component) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.entry(tc, "destroyOldEngineComponent", component);
        }

        boolean removed = jmeComponents.remove(component);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            SibTr.debug(tc, "destroyOldEngineComponent, component removed from jmeComponents?", removed);
        }

        JsEngineComponent engineComponent = component.getRef();

        if (_state == STATE_STARTING || _state == STATE_STARTED || _state == STATE_STOPPING || _state == STATE_STOPPING_MEMBER || _state == STATE_FAILED) {
            // Stop engine component
            engineComponent.stop(JsConstants.ME_STOP_IMMEDIATE);
        }

        if (_state != STATE_UNINITIALIZED && _state != STATE_DESTROYED) {
            // Destroy
            engineComponent.destroy();
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            SibTr.exit(tc, "destroyOldEngineComponent");
        }
    }
836485
public void removeEmptySubtrees(CmsTreeNode<I_CmsContextMenuItem> root) {

        List<CmsTreeNode<I_CmsContextMenuItem>> children = root.getChildren();
        if ((root.getData() != null) && root.getData().isLeafItem()) {
            children.clear();
        } else {
            Iterator<CmsTreeNode<I_CmsContextMenuItem>> iter = children.iterator();
            while (iter.hasNext()) {
                CmsTreeNode<I_CmsContextMenuItem> node = iter.next();
                removeEmptySubtrees(node);
                if ((node.getData() != null) && !node.getData().isLeafItem() && (node.getChildren().size() == 0)) {
                    iter.remove();
                }
            }
        }
    }
1364877
private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.add(getBtnCancel(), null);
			jPanel1.add(getBtnReset(), null);
			jPanel1.add(getBtnApply(), null);
		}
		return jPanel1;
	}
966598
public static void closeModal(Component component) {
	synchronized (modals) {
	  RootPaneContainer frame = null;
	  Modal modal = null;

	  Iterator<Entry<RootPaneContainer, Modal>> it =
		  modals.entrySet().iterator();
	  while (it.hasNext()) {
		Entry<RootPaneContainer, Modal> entry = it.next();
		modal = entry.getValue();
		frame = entry.getKey();
		if (frame != null && modal != null
			&& modal.components.contains(component)) {
		  break;
		} else {
		  frame = null;
		  modal = null;
		}
	  }
	  if (frame != null && modal != null) {
		modal.close(component);
		if (modal.getSize() == 0) {
		  modals.remove(frame);
		}
	  }
	}
  }
338178
private void uninstallLayout(JRootPane root) {
        if (savedOldLayout != null) {
            root.setLayout(savedOldLayout);
            savedOldLayout = null;
        }
    }