Visits (possibly nested) block statements and returns the first child statement with the given
class.
330326
private static <T> T getChild(StatementTree tree, final Class<T> clazz) {
    return tree.accept(
        new SimpleTreeVisitor<T, Void>() {
          @Override
          protected T defaultAction(Tree node, Void p) {
            if (clazz.isInstance(node)) {
              return clazz.cast(node);
            }
            return null;
          }

          @Override
          public T visitBlock(BlockTree node, Void p) {
            return visit(node.getStatements());
          }

          private T visit(List<? extends Tree> tx) {
            for (Tree t : tx) {
              T r = t.accept(this, null);
              if (r != null) {
                return r;
              }
            }
            return null;
          }
        },
        null);
  }
1260154
function oneLevelChildren( &$contentTree, &$classFilter, &$sortBy, &$nodesLeft, $fetchHidden )
    {
        $parentNode = $contentTree['parent_node'];

        if ( !is_array( $parentNode ) || count( $parentNode['node'] ) == 0 )
        {
            return false;
        }

        if ( !$parentNode['object']['is_container'] || $parentNode['node']['children_count'] == 0 )
        {
            return true;
        }

        // fill parent node attributes
        if ( $nodesLeft != 0)
        {
            // get children
            $sortArray = ( $sortBy == false ) ? $parentNode['node']['sort_array'] : $sortBy;

            $children = eZContentStructureTreeOperator::subTree( array(  'SortBy' => $sortArray,
                                                                         'ClassFilterType' => 'include',
                                                                         'ClassFilterArray'=> $classFilter,
                                                                         'NodePath' => $parentNode['node']['path_string'],
                                                                         'NodeDepth' => $parentNode['node']['depth'],
                                                                         'FetchHidden' => $fetchHidden ),
                                                                 $parentNode['node']['node_id'] );
            if ( $children && count( $children ) > 0 )
            {
                $childrenNodes =& $contentTree['children'];
                // fill children attributes
                foreach ( $children as $child )
                {
                    $childrenCount = 0;

                    if ( $child['is_container'] == '1' )
                    {
                        $childrenCount = eZContentStructureTreeOperator::subTree( array(  'SortBy' => false,
                                                                              'ClassFilterType' => 'include',
                                                                              'ClassFilterArray'=> $classFilter,
                                                                              'NodePath' => $child['path_string'],
                                                                              'NodeDepth' => $child['depth'],
                                                                              'FetchHidden' => $fetchHidden ),
                                                                      $child['node_id'],
                                                                      true );
                    }

                    $childNode = eZContentStructureTreeOperator::createContentStructureNode( $child, $childrenCount );

                    $childrenNodes[] = array( 'parent_node' => $childNode,
                                              'children' => array() );

                    --$nodesLeft;
                    if ( $nodesLeft == 0 )
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        return false;
    }
332288
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
		in.defaultReadObject();
		if (this.children != null) {
			final N me = toN();
			for (final NaryTreeNode<D, N> child : this.children) {
				if (child != null) {
					child.setParentNodeReference(me, false);
				}
			}
		}
	}
585485
function getFirstChildElement(parent) {
  var cursor = parent.firstChild;

  while (cursor && cursor.nodeType !== 1) {
    cursor = cursor.nextSibling;
  }
  return cursor;
}
406760
def each(&block)
      return enum_for(:each) unless block_given?

      child = first_child
      while child
        nextchild = child.next
        yield child
        child = nextchild
      end
    end
506304
@Override
    public int first() {
        fCachedBreakPositions = null;
        fDictionaryCharCount = 0;
        fPositionInCache = 0;
        fLastRuleStatusIndex  = 0;
        fLastStatusIndexValid = true;
        if (fText == null) {
            return BreakIterator.DONE;
        }
        fText.first();
        return fText.getIndex();
    }
1341750
public void visitClass(ClassNode node) {
        // AIC are already done, doing them here again will lead to wrong scopes
        if (isAnonymous(node)) return;

        pushState();

        prepareVisit(node);

        super.visitClass(node);
        if (recurseInnerClasses) {
            Iterator<InnerClassNode> innerClasses = node.getInnerClasses();
            while (innerClasses.hasNext()) {
                visitClass(innerClasses.next());
            }
        }
        popState();
    }
489338
def _parse_block(self, block, node):
        '''
        
        '''
        assert block[self.get_key()] == 'Block'

        if self.is_compact_ast:
            statements = block['statements']
        else:
            statements = block[self.get_children('children')]

        for statement in statements:
            node = self._parse_statement(statement, node)
        return node
1187405
protected static <T> Class<T> firstKnownType(T... objects) {
        for (T obj : objects)
            if (obj != null)
                return (Class<T>) obj.getClass();
        return null;
    }
1195769
def firstElementChild(self) -> Optional[AbstractNode]:
        
        for child in self.childNodes:
            if child.nodeType == Node.ELEMENT_NODE:
                return child
        return None
1183024
public int getChildCount(Class<? extends ElementBase> clazz) {
        if (clazz == ElementBase.class) {
            return getChildCount();
        }
        
        int count = 0;
        
        for (ElementBase child : children) {
            if (clazz.isInstance(child)) {
                count++;
            }
        }
        
        return count;
    }
619101
protected Block visitBlock(Block block) {
        if (block == null) {
            return null;
        }

        Statement stmt = (Statement)block.accept(this);

        if (stmt instanceof Block) {
            return (Block)stmt;
        }
        else if (stmt != null) {
            return new Block(stmt);
        }
        else {
            return new Block(block.getSourceInfo());
        }
    }
188733
private Statement classStatement(final Statement base) {
        return new Statement() {

            @Override
            public void evaluate() throws Throwable {
                beforeClass();
                doStateTransition(State.BEFORE_EXECUTED);
                try {
                    base.evaluate();
                } finally {
                    afterClass();
                    doStateTransition(State.AFTER_EXECUTED);
                }
            }
        };
    }
528063
@Nullable
  public static ClassTree findClass(ClassSymbol symbol, VisitorState state) {
    return JavacTrees.instance(state.context).getTree(symbol);
  }
363724
def child_class(self, child):
        
        for prop, klassdef in self.c_children.values():
            if child == prop:
                if isinstance(klassdef, list):
                    return klassdef[0]
                else:
                    return klassdef
        return None
58613
def initialize(self):
        
        super(Block, self).initialize()
        if self.block:
            self.block.parent.insert_children(self.block, self.children)
378788
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            JavaClass cls = classContext.getJavaClass();
            if (isSingleton(cls)) {
                syncBlockBranchResetValues = new HashMap<>();
                stack = new OpcodeStack();
                super.visitClassContext(classContext);
            }
        } finally {
            syncBlockBranchResetValues = null;
            stack = null;
        }
    }