Creates a mutable list whose first element is {@code node}, and last element is its root parent.
171517
public static <T> List<T> toRoot(TreeDef.Parented<T> treeDef, T node) {
		List<T> list = new ArrayList<>();
		T tip = node;
		while (tip != null) {
			list.add(tip);
			tip = treeDef.parentOf(tip);
		}
		return list;
	}
940039
def ancestors
      node  = self
      nodes = []
      nodes << node = node.parent while node.parent
      nodes
    end
259901
public void insertParentAfter(Node node) throws ChildNodeException {
    if (node != null) {
      // give this node my children
      node.setFirstChild(getFirstChild());

      setFirstChild(null); // clear our list
      addChild(node);      // make our child
    }
  }
647217
public static <T> Partition<T> singletons(Collection<T> nodes) {
        final Map<T, T> parents = Maps.newHashMap();
        final Map<T, Integer> ranks = Maps.newHashMap();
        for (T node : nodes) {
            parents.put(node, node); // each node is its own head
            ranks.put(node, 0); // every node has depth 0 to start
        }
        return new Partition<T>(parents, ranks);
    }
92000
protected int addNodeInDocOrder(int node)
   {
      assertion(hasCache(), "addNodeInDocOrder must be done on a mutable sequence!");

      int insertIndex = -1;
      
      NodeVector vec = getVector();

      // This needs to do a binary search, but a binary search 
      // is somewhat tough because the sequence test involves 
      // two nodes.
      int size = vec.size(), i;

      for (i = size - 1; i >= 0; i--)
      {
        int child = vec.elementAt(i);

        if (child == node)
        {
          i = -2; // Duplicate, suppress insert

          break;
        }

        DTM dtm = m_dtmMgr.getDTM(node);
        if (!dtm.isNodeAfter(node, child))
        {
          break;
        }
      }

      if (i != -2)
      {
        insertIndex = i + 1;

        vec.insertElementAt(node, insertIndex);
      }

      // checkDups();
      return insertIndex;
    }
1030765
public static List<Element> getChildren(Element parent, String childName) {
		ArrayList<Element> children = new ArrayList<Element>();
		NodeList nodes = parent.getChildNodes();
		for (int i = 0; i < nodes.getLength(); ++i) {
			Node node = nodes.item(i);
			if ((node instanceof Element) && node.getNodeName().equals(childName))
				children.add((Element)node);
		}
		return children;
	}
1285747
public SharedTreeNode makeLeftChildNode(SharedTreeNode parent) {
    SharedTreeNode child = new SharedTreeNode(nodesArray.size(), parent, subgraphNumber, parent.getDepth() + 1);
    nodesArray.add(child);
    makeLeftEdge(parent, child);
    return child;
  }
1069807
public List<Expression> execOnChildren(ParentSoyNode<?> node) {
    Preconditions.checkArgument(isComputableAsJsExprsVisitor.execOnChildren(node));
    chunks = new ArrayList<>();
    visitChildren(node);
    return chunks;
  }
1363579
private ImmutableNode mapToNode(final Builder builder, final Map<String, Object> map) {
        for (final Map.Entry<String, Object> entry : map.entrySet()) {
            final String key = entry.getKey();
            final Object value = entry.getValue();
            if (value instanceof List) {
                // For a list, add each list item as a child of this node.
                for (final Object item : (List)value) {
                    addChildNode(builder, key, item);
                }
            } else {
                // Otherwise, add the value as a child of this node.
                addChildNode(builder, key, value);
            }
        }
        return builder.create();
    }
422112
@Override
	public void traverse(final ITreeNode<T> node, final List<ITreeNode<T>> list)
	{
		list.add(node);
		for (final ITreeNode<T> data : node.getChildren())
		{
			traverse(data, list);
		}
	}
1051578
public Tree<T> add(Tree<T> node) {
    node.removeFromParent();
    node.parent = this;
    children.add(node);
    return node;
  }
140242
function(node) {
			var classes,
				out = [],
				obj,
				itemRootID;

			// loop roots found on one element
			classes = this.getUfClassNames(node);
			if(classes && classes.root.length && classes.root.length > 0){

				this.rootID++;
				itemRootID = this.rootID;
				obj = this.createUfObject(classes.root, classes.typeVersion);

				this.walkChildren(node, obj, classes.root, itemRootID, classes);
				if(this.impliedRules){
					this.impliedRules(node, obj, classes);
				}

				if(this.options.lang === true){
					var lang = modules.domUtils.getFirstAncestorAttribute(node, 'lang');
					if(lang){
						obj.lang = lang;
					}
				}
				out.push( this.cleanUfObject(obj) );


			}
			return out;
		}
232190
private GBSNode lastInList(
    GBSNode       p)
  {
    GBSNode q = p;
    p = p.rightChild();
    while (p != null)
    {
      q = p;
      p = p.rightChild();
    }
    return q;
  }
869571
public List<Node<Scope>> toList() {
        List<Node<Scope>> list = new ArrayList<Node<Scope>>();
        walk(rootElement, list);
        return list;
    }
568369
public static void add(Element parent, NodeList list) {
        int size;
        int i;

        size = list.getLength();
        for (i = 0; i < size; i++) {
            addNode(parent, list.item(i));
        }
        
    }
271382
public static <T extends HierarchyEntity<T, ?>> void addParent(Collection<T> nodes) {
    addParent(nodes, null);
  }
883354
public Node createNode( Tree<Row> current ){
        Row row = current.getContent();
        Element output = row.getOutputElement();
        Element main = row.getMainElement();
        List<Element> input = row.getInputElement();
        Integer id = main.getId();
        Type type = main.getType();
        switch( type ) {
            case START:
                return null;
            case END:
                return null;
            case VALUE:
                String vAttribute = output.getString( 0 );
                Object value = main.getObject( 0 );
                return new SetAttributeActivity( id, vAttribute, value );
            case CALL:
                String cBean = main.getString( 0 );
                String cMethod = main.getString( 1 );
                InputMapping<?>[] cArgumentsMapping = ElementUtil.createArrayMapping( main.getObjectArray( 2 ) );
                OutputMapping cOutputMapping = ElementUtil.createOutputMapping( output );
                return new BeanCallActivity( id, cBean, cMethod, cArgumentsMapping, cOutputMapping );
            case CALL_ASYNC:
                String caBean = main.getString( 0 );
                String caMethod = main.getString( 1 );
                InputMapping<?>[] caArgumentsMapping = ElementUtil.createArrayMapping( main.getObjectArray( 2 ) );
                OutputMapping caOutputMapping = ElementUtil.createOutputMapping( output );
                return new BeanAsyncCallActivity( id, caBean, caMethod, caArgumentsMapping, caOutputMapping );
            case HUMAN_TASK:
                String role = main.getString( 0 );
                String user = main.getString( 1 );
                MapMapping htArgumentsMapping = ElementUtil.createMapMapping( input );
                OutputMapping htOutputMapping = ElementUtil.createOutputMapping( output );
                return new HumanTaskActivity( id, role, user, htArgumentsMapping, htOutputMapping );
            case WAIT_SIGNAL:
                String signal = main.getString( 0 );
                OutputMapping wsOutputMapping = ElementUtil.createOutputMapping( output );
                return new CatchSignal( id, signal, wsOutputMapping );
            case WAIT_TIMER:
                String due = main.getString( 0 );
                if( ElUtil.hasBrackets( due ) ){
                    return new CatchTimer( new ExpressionLanguageMapping<Long>( due ), id );
                }
                else{
                    long delayMillis = Long.valueOf( due );
                    return new CatchTimer( id, delayMillis );
                }
            case WAIT_UNTIL_DATE:
                String dueDate = main.getString( 0 );
                return new CatchTimer( id, new ExpressionLanguageMapping<Date>( dueDate ) );
            case CREATE_INSTANCE:
                String graphName = main.getString( 0 );
                InputMapping<String> nameMapping = ElUtil.hasBrackets( graphName ) ?
                        new ExpressionLanguageMapping<String>( graphName ) : ConstantMapping.of( graphName );

                Integer graphVersion = main.getInteger( 1 );
                InputMapping<Integer> versionMapping = ConstantMapping.of( graphVersion );

                String label1 = main.getString( 2 );
                InputMapping<String> label1Mapping = ElUtil.hasBrackets( label1 ) ?
                        new ExpressionLanguageMapping<String>( label1 ) : ConstantMapping.of( label1 );

                String label2 = main.getString( 3 );
                InputMapping<String> label2Mapping = ElUtil.hasBrackets( label2 ) ?
                        new ExpressionLanguageMapping<String>( label2 ) : ConstantMapping.of( label2 );

                MapMapping ciArgumentsMapping = ElementUtil.createMapMapping( input );

                return new CreateNewInstanceActivity( id, nameMapping, versionMapping, label1Mapping, label2Mapping, ciArgumentsMapping );
            case WHILE_DO_BEGIN:
                return new XorFork( id );
            case WHILE_DO_END:
                id = -findPartnerNodeId( current, type );
                return new XorJoin( id );
            case DO_WHILE_BEGIN:
                id = -findPartnerNodeId( current, type );
                return new XorJoin( id );
            case DO_WHILE_END:
                return new XorFork( id );
            case IF:
                return new XorFork( id );
            case ELSE_IF:
                return null;
            case ELSE:
                return null;
            case END_IF:
                id = -findPartnerNodeId( current, type );
                return new XorJoin( id );
            case SPLIT:
                boolean hasConditionalBranches = hasConditionalBranches( current );
                return hasConditionalBranches ? new OrFork( id ) : new AndFork( id );
            case BRANCH:
                return null;
            case JOIN_FIRST:
                id = -findPartnerNodeId( current, type );
                return new CancellingDiscriminator( id );
            case JOIN_ALL:
                id = -findPartnerNodeId( current, type );
                return new AndJoin( id );
            case ESCALATE:
                return new ThrowEscalation( id );
            case VALIDATE_INPUT_VARIABLE:
                String vivAttribute = main.getString( 0 );
                Class<?> vivType = (Class<?>)main.getObject( 1 );
                if( main.countArguments() == 2 ){
                    return new ValidateAttributeActivity( id, vivAttribute, vivType );
                }
                boolean vivIsRequired = (boolean)main.getObject( 2 );
                if( main.countArguments() == 3 ){
                    return new ValidateAttributeActivity( id, vivAttribute, vivType, vivIsRequired );
                }
                Object vivDefaultValue = main.getObject( 3 );
                return new ValidateAttributeActivity( id, vivAttribute, vivType, vivIsRequired, vivDefaultValue );
            default :
                throw new IllegalStateException( "Cannot create node for unknown main element type in row: " + row );
        }
    }