public static boolean forEachChild(Node parent,NodeVisitor visitor){
  CompilerAsserts.neverPartOfCompilation("do not iterate over Node children from compiled code");
  Objects.requireNonNull(visitor);
  NodeClass nodeClass=parent.getNodeClass();
  for (  Object field : nodeClass.getNodeFields()) {
    if (nodeClass.isChildField(field)) {
      Object child=nodeClass.getFieldObject(field,parent);
      if (child != null) {
        if (!visitor.visit((Node)child)) {
          return false;
        }
      }
    }
 else     if (nodeClass.isChildrenField(field)) {
      Object arrayObject=nodeClass.getFieldObject(field,parent);
      if (arrayObject != null) {
        Object[] array=(Object[])arrayObject;
        for (int i=0; i < array.length; i++) {
          Object child=array[i];
          if (child != null) {
            if (!visitor.visit((Node)child)) {
              return false;
            }
          }
        }
      }
    }
 else     if (nodeClass.nodeFieldsOrderedByKind()) {
      break;
    }
  }
  return true;
}

public static boolean forEachChild ( Node parent , NodeVisitor visitor ) { CompilerAsserts . neverPartOfCompilation ( "do not iterate over Node children from compiled code" ) ; Objects . requireNonNull ( visitor ) ; NodeClass nodeClass = parent . getNodeClass ( ) ; for ( Object field : nodeClass . getNodeFields ( ) ) { if ( nodeClass . isChildField ( field ) ) { Object child = nodeClass . getFieldObject ( field , parent ) ; if ( child != null ) { if ( ! visitor . visit ( ( Node ) child ) ) { return false ; } } } else if ( nodeClass . isChildrenField ( field ) ) { Object arrayObject = nodeClass . getFieldObject ( field , parent ) ; if ( arrayObject != null ) { Object [ ] array = ( Object [ ] ) arrayObject ; for ( int i = 0 ; i < array . length ; i ++ ) { Object child = array [ i ] ; if ( child != null ) { if ( ! visitor . visit ( ( Node ) child ) ) { return false ; } } } } } else if ( nodeClass . nodeFieldsOrderedByKind ( ) ) { break ; } } return true ; }
executes a closure for every non - null child of the parent node .
