Compute all descendants of the given node in the given tree model

@param treeModel The tree model
@param node The node
@param result The descendants
8841
private static void getAllDescendants(
        TreeModel treeModel, Object node, List<Object> result)
    {
        if (node == null)
        {
            return;
        }
        result.add(node);
        List<Object> children = getChildren(treeModel, node);
        for (Object child : children)
        {
            getAllDescendants(treeModel, child, result);
        }
    }
245039
public void show(ManagementModelNode node, int x, int y) {
        removeAll();
        addExploreOption(node);

        String addressPath = node.addressPath();
        try {
            ModelNode  opNames = executor.doCommand(addressPath + ":read-operation-names");
            if (opNames.get("outcome").asString().equals("failed")) return;

            for (ModelNode name : opNames.get("result").asList()) {
                String strName = name.asString();

                // filter operations
                if (node.isGeneric() && !genericOpList.contains(strName)) continue;
                if (node.isLeaf() && !leafOpList.contains(strName)) continue;
                if (!node.isGeneric() && !node.isLeaf() && strName.equals("add")) continue;

                ModelNode opDescription = getResourceDescription(addressPath, strName);
                add(new OperationAction(node, strName, opDescription));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        super.show(invoker, x, y);
    }
592734
public static void mergeNodeChildren(TreeNode node) {
        DefaultMutableTreeNode masterNode = (DefaultMutableTreeNode) node;

        // The rules are there are no rules. Nothing else needs to be done
        // except for merging through the children
        for (int i = 0; i < masterNode.getChildCount(); i++) {
            DefaultMutableTreeNode child = (DefaultMutableTreeNode) masterNode.getChildAt(i);

            if (!child.isLeaf()) {
                MergeHelpUtilities.mergeNodeChildren(DEFAULT_MERGE_TYPE, child);
            }
        }
    }
50266
protected function _createTree( MW_DB_Result_Interface $result, MW_Tree_Node_Interface $node )
	{
		while( ( $record = $result->fetch() ) !== false )
		{
			$newNode = $this->_createNode( $record );

			while( $this->_isChild( $newNode, $node ) )
			{
				$node->addChild( $newNode );

				if( ( $newNode = $this->_createTree( $result, $newNode ) ) === false ) {
					return false;
				}
			}

			return $newNode;
		}

		return false;
	}
1214378
private void processNode(final Node node) {
        processNode(node.getPath(), node);

        Set<Node> children = node.getChildren();
        for (Node child : children) {
            processNode(child);
        }
    }
681328
public static NodeStepResult with(final NodeStepResult result, final WFSharedContext dataContext) {
        return new NodeStepDataResultImpl(
                result,
                result.getException(),
                result.getFailureReason(),
                result.getFailureMessage(),
                result.getFailureData(),
                result.getNode(),
                dataContext
        );
    }
629967
@SuppressWarnings("unchecked")
    public static Iterator<TreeNode> iterator(TreeNode self) {
        return (Iterator<TreeNode>) DefaultGroovyMethods.iterator(self.children());
    }
1341311
protected List<R> visitChildren(ParentNode<? extends N> node) {
    List<R> results = new ArrayList<>(node.numChildren());
    for (N child : node.getChildren()) {
      results.add(visit(child));
    }
    return results;
  }
1102652
private void processCustomIdNodeMapping(final Map<String, TreeItemIdNode> map, final TreeItemIdNode node) {
		String itemId = node.getItemId();
		if (!Util.empty(itemId)) {
			map.put(itemId, node);
		}

		for (TreeItemIdNode childItem : node.getChildren()) {
			processCustomIdNodeMapping(map, childItem);
		}
	}
387505
@SuppressWarnings("unchecked")
    public <T extends TreeNode> TreeNode treeFrom(Object source)
            throws IOException, JSONObjectException
    {
        if (_treeCodec == null) {
             _noTreeCodec("read TreeNode");
        }
        if (source instanceof JsonParser) {
            JsonParser p = _initForReading((JsonParser) source);
            T result = (T) _treeCodec.readTree(p);
            p.clearCurrentToken();
            return result;
        }
        JsonParser p = _parser(source);
        try {
            _initForReading(_config(p));
            T result = (T) _treeCodec.readTree(p);
            JsonParser p0 = p;
            p = null;
            _close(p0, null);
            return result;
        } catch (Exception e) {
            _close(p, e);
            return null;
        }
    }
874132
private DefaultTreeModel getTreeModel() {
        if (treeModel == null) {
            treeModel = new DefaultTreeModel(getRootNode());
            treeModel.setRoot(getRootNode());
        }
        
        return treeModel;
    }
1279563
private void getDescendants(Entity entity, LdapEntry ldapEntry, DescendantControl descCtrl) throws WIMException {
        if (descCtrl == null) {
            return;
        }

        List<String> propNames = descCtrl.getProperties();
        int level = descCtrl.getLevel();
        List<String> descTypes = getEntityTypes(descCtrl);
        String[] bases = getBases(descCtrl, descTypes);
        boolean treeView = descCtrl.isSetTreeView();
        int scope = SearchControls.ONELEVEL_SCOPE;
        if (level == 0 && !treeView) {
            scope = SearchControls.SUBTREE_SCOPE;
        }
        Set<String> descToDo = new HashSet<String>();
        Map<String, Entity> descendants = new HashMap<String, Entity>();
        Set<LdapEntry> descEntries = iLdapConn.searchEntities(ldapEntry.getDN(), "objectClass=*", null, scope, descTypes,
                                                              propNames, false, false);
        for (LdapEntry descEntry : descEntries) {
            String descType = descEntry.getType();
            String descDn = descEntry.getDN();
            Entity descendant = null;
            if (LdapHelper.isUnderBases(descDn, bases) && descTypes.contains(descType)) {
                descendant = createEntityFromLdapEntry(entity, SchemaConstants.DO_CHILDREN, descEntry, propNames);
            } else if (treeView) {
                descendant = createEntityFromLdapEntry(entity, SchemaConstants.DO_CHILDREN, descEntry, null);
            }
            if (treeView) {
                descToDo.add(descDn);
                descendants.put(descDn, descendant);
            }
        }
        if (treeView) {
            while (descToDo.size() > 0) {
                Set<String> nextDescs = new HashSet<String>();
                for (String dn : descToDo) {
                    Entity parent = descendants.get(dn);
                    descEntries = iLdapConn.searchEntities(dn, "objectClass=*", null, scope, descTypes, propNames,
                                                           false, false);
                    for (LdapEntry descEntry : descEntries) {
                        String descType = descEntry.getType();
                        String descDn = descEntry.getDN();
                        Entity descendant = null;
                        if (descTypes.contains(descType)) {
                            descendant = createEntityFromLdapEntry(parent, SchemaConstants.DO_CHILDREN, descEntry, propNames);
                        } else if (treeView) {
                            descendant = createEntityFromLdapEntry(parent, SchemaConstants.DO_CHILDREN, descEntry, null);
                        }
                        if (!descToDo.contains(descDn)) {
                            nextDescs.add(descDn);
                            descendants.put(descDn, descendant);
                        }
                    }
                }
                descToDo = nextDescs;
            }
        }
    }
699628
private static <T extends HierarchyEntity<T, ?>> void loadChildren(T node, Set<T> children) {
    if (null == node.getChildren()) { return; }
    for (T one : node.getChildren()) {
      children.add(one);
      loadChildren(one, children);
    }
  }
128115
private static void getLeafNodes(
        TreeModel treeModel, Object node, Collection<Object> leafNodes)
    {
        if (node == null)
        {
            return;
        }
        int childCount = treeModel.getChildCount(node);
        if (childCount == 0)
        {
            leafNodes.add(node);
        }
        else
        {
            for (int i = 0; i < childCount; i++)
            {
                Object child = treeModel.getChild(node, i);
                getLeafNodes(treeModel, child, leafNodes);
            }
        }
    }
969713
private void trimNode(final Node node) {
        NodeList children = node.getChildNodes();
        for (int i = children.getLength() - 1; i >= 0; i--) {
            trimChild(node, children.item(i));
        }
    }
1318427
@Override
    public void onViewChild(ModelNode address, String childName) {
        TreeItem rootNode = findTreeItem(tree, address);
        TreeItem childNode = null;
        for(int i=0; i<rootNode.getChildCount(); i++)
        {
            TreeItem candidate = rootNode.getChild(i);
            if(childName.equals(candidate.getText()))
            {
                childNode = candidate;
                break;
            }
        }

        if(null==childNode)
            throw new IllegalArgumentException("No such child "+ childName + " on "+ address.toString());


        // deselect previous
        tree.setSelectedItem(null, false);

        // select next
        tree.setSelectedItem(childNode, false);
        tree.ensureSelectedItemVisible();

        onItemSelected(childNode);
    }
660049
private void getLeafNodes(N node, List<E> result, int currentLevel) {
    // Level 1 are the leaf nodes, Level 2 is the one atop!
    if(currentLevel == 2) {
      for(int i = 0; i < node.getNumEntries(); i++) {
        result.add(node.getEntry(i));
      }
    }
    else {
      for(int i = 0; i < node.getNumEntries(); i++) {
        getLeafNodes(getNode(node.getEntry(i)), result, (currentLevel - 1));
      }
    }
  }