Traverse the tree.

In MicrodataJS, this is handled using a closure.
See comment for MicrodataPhp:getObject() for an explanation of closure use
in this library.
968617
protected function traverse($node, &$toTraverse, &$props, $root) {
    foreach ($toTraverse as $i => $elem)  {
      if ($elem->isSameNode($node)){
        unset($toTraverse[$i]);
      }
    }
    if (!$root->isSameNode($node)) {
      $names = $node->itemProp();
      if (count($names)) {
        //@todo Add support for property name filtering.
        $props[] = $node;
      }
      if ($node->itemScope()) {
        return;
      }
    }
    if (isset($node)) {
      // An xpath expression is used to get children instead of childNodes
      // because childNodes contains DOMText children as well, which breaks on
      // the call to getAttributes() in itemProp().
      $children = $this->ownerDocument->xpath()->query($node->getNodePath() . '/*');
      foreach ($children as $child) {
        $this->traverse($child, $toTraverse, $props, $root);
      }
    }
  }
596456
function traverseChildren(tw, type) {
  var child, node, parent, result, sibling;
  node = tw._currentNode[mapChild[type]];
  while (node !== null) {
    result = tw._internalFilter(node);
    if (result === NodeFilter.FILTER_ACCEPT) {
      tw._currentNode = node;
      return node;
    }
    if (result === NodeFilter.FILTER_SKIP) {
      child = node[mapChild[type]];
      if (child !== null) {
        node = child;
        continue;
      }
    }
    while (node !== null) {
      sibling = node[mapSibling[type]];
      if (sibling !== null) {
        node = sibling;
        break;
      }
      parent = node.parentNode;
      if (parent === null || parent === tw.root || parent === tw._currentNode) {
        return null;
      } else {
        node = parent;
      }
    }
  }
  return null;
}
309199
def _traverse_child_objs(self, goobj_parent):
        """"""
        parent_id = goobj_parent.id
        # mark parent as seen
        self.seen_pids.add(parent_id)
        self.godag.go2obj[parent_id] = goobj_parent
        # Loop through children
        for child_obj in goobj_parent.children:
            child_id = child_obj.id
            self.godag.p2cs[parent_id].add(child_id)
            # If child has not been seen
            if child_id not in self.seen_pids:
                self._traverse_child_objs(child_obj)
597661
function getObjectByKey(data, prop) {
    if (!prop || !~prop.indexOf('.')) return data[prop];

    var result = prop
      , structure = data;

    for (var paths = prop.split('.'), i = 0, length = paths.length; i < length; i++) {
      result = structure[+paths[i] || paths[i]];
      structure = result;
    }

    return result || data[prop];
  }
606476
@Override
    public Object getChild(Object nodeObj, int i) {
        if (debugger == null) {
            return null;
        }
        VariableNode node = (VariableNode) nodeObj;
        return children(node)[i];
    }
105835
QNode traversalHead() {
    for (;;) {
      QNode t = this.tail.get();
      QNode h = this.head.get();
      if (h != null && t != null) {
        QNode last = t.next;
        QNode first = h.next;
        if (t == this.tail.get()) {
          if (last != null) {
            this.tail.compareAndSet(t, last);
          } else if (first != null) {
            Object x = first.get();
            if (x == first) {
              advanceHead(h, first);
            } else {
              return h;
            }
          } else {
            return h;
          }
        }
      }
    }
  }
154190
function Tree(details) {

		// If the details are not an Object
		if(!is.object(details)) {
			throw 'details must be an Object';
		}

		// If the name is not set
		if(!('__name__' in details)) {
			throw '"__name__" not found in details';
		}

		// If the name is not valid
		if(!_standardField.test(details['__name__'])) {
			throw '"__name__" not a valid value for Tree';
		}

		// Store the name then delete it
		var _name = details['__name__'];
		delete details['__name__'];

		// If for some reason the array flag is set, remove it
		if('__array__' in details) {
			delete details['__array__'];
		}

		// Call the parent constructor
		Parent.call(this, details);

		/**
		 * To Object
		 *
		 * Returns the Node as a dictionary in the same format as is used in
		 * constructing it
		 *
		 * @name toObject
		 * @return Object
		 */
		this.toObject = function toObject() {

			// Init the Object we will return
			var oRet = {
				"__name__": _name
			}

			// Get the parents dict and add it to the return
			var oParent = Parent.prototype.toObject.call(this);
			for(var k in oParent) {
				oRet[k] = oParent[k];
			}

			// Return
			return oRet;
		}

		/**
		 * Type
		 *
		 * Returns the type of Node
		 *
		 * @name type
		 * @access public
		 * @return String
		 */
		this.type = function type() {
			return 'Tree';
		}

		/**
		 * Valid
		 *
		 * Checks if the passed dict has the right values for this Parent
		 *
		 * @name valid
		 * @param Object value				The value to validate
		 * @return bool
		 */
		this.valid = function valid(value, include_name) {

			// If the include_name param wasn't sent, assume true
			if(typeof include_name == 'undefined') {
				include_name = true;
			}

			// Call the Parent valid method
			return Parent.prototype.valid.call(this, value, (include_name ? [_name] : []));
		}
	}
1133951
def find_value_in_object(attr, obj):
    

    # Carry on inspecting inside the list or tuple
    if isinstance(obj, (collections.Iterator, list)):
        for item in obj:
            yield from find_value_in_object(attr, item)

    # Final object (dict or entity) inspect inside
    elif isinstance(obj, collections.Mapping):

        # If result is found, inspect inside and return inner results
        if attr in obj:

            # If it is iterable, just return the inner elements (avoid nested
            # lists)
            if isinstance(obj[attr], (collections.Iterator, list)):
                for item in obj[attr]:
                    yield item

            # If not, return just the objects
            else:
                yield obj[attr]

        # Carry on inspecting inside the object
        for item in obj.values():
            if item:
                yield from find_value_in_object(attr, item)
611452
def traverser(self, data, schema, tree):
        
        if hasattr(schema, '__validator_leaf__'):
            return schema(data, tree)

        if hasattr(schema, 'must_validate'):  # cherry picking?
            if not len(schema.must_validate):
                reason = "must_validate attribute must not be empty"
                raise SchemaError(data, tree, reason=reason)
            data = sift(data, schema.must_validate)

        schema = self.sanitize_optionals(data, schema, tree)
        self.is_alpha_ordered(data, schema, tree)

        validated_indexes = []
        skip_missing_indexes = getattr(schema, 'must_validate', False)

        if len(data) < len(schema):
            # we have missing required items in data, but we don't know
            # which ones so find what may fail:
            data_keys = [v[0] for v in data.values()]
            schema_keys = [v[0] for v in schema.values()]

            def enforce_once(data_keys, schema_key):
                # XXX Go through all the data keys and try and see if they pass
                # validation against the schema. At this point it is impossible
                # to know which data key corresponds to what schema key
                # (because schema keys can be a function/callable) so it is
                # a *very* naive way to try and detect which one might be
                # missing
                for data_key in data_keys:
                    failed = None
                    try:
                        enforce(data_key, schema_key, tree, pair='key')
                        return
                    except Invalid:
                        failed = data_key, schema_key

                    if failed:
                        return failed

            # if there are no callables in the schema keys, just
            # find the missing data key directly
            if all([not is_callable(s) for s in schema_keys]):
                for schema_key in schema_keys:
                    if schema_key not in data_keys:
                        msg = "required key in data is missing: %s" % str(schema_key)
                        raise Invalid(None, tree, reason=msg, pair='key')

            for schema_key in schema_keys:
                failure = enforce_once(data_keys, schema_key)
                if failure:
                    _, failed_schema_key = failure
                    msg = "required key in data is missing: %s" % str(failed_schema_key)
                    raise Invalid(None, tree, reason=msg, pair='key')

        for index in range(len(data)):
            self.length_equality(data, schema, index, tree)
            key, value = data[index]
            skey, svalue = schema[index]
            tree.append(key)

            # Validate the key before anything, to prevent recursing
            self.key_leaf(data[index], schema[index], tree)

            # If a dict is a value we need to recurse.
            # XXX Should we check isinstance(value, ndict) ?
            if isinstance(value, dict) and len(value):
                self.traverser(value, svalue, tree)
            else:
                self.value_leaf(data[index], schema[index], tree)
            if tree:
                tree.pop()

            validated_indexes.append(index)

        # XXX There is a chance we might have missing items from
        # the incoming data that are labeled as required from the schema
        # we should make sure *here* that we account for that and raise
        # the appropriate exception. Since the loop finished and everything
        # seems to have passed, this lack of check will give false positives.
        missing_indexes = set(schema.keys()).difference(validated_indexes)
        if missing_indexes:
            if skip_missing_indexes:
                return
            for i in missing_indexes:
                if not hasattr(schema[i], 'is_optional'):
                    required_key = schema[i][0]
                    tree.append('item[%s]' % i)
                    msg = "required item in schema is missing: %s" % str(required_key)
                    raise Invalid(required_key, tree, reason=msg, pair='key')
518366
def traverse(obj, *path, **kwargs):
    
    if path:
        if isinstance(obj, list) or isinstance(obj, tuple):
            #If the current state of the object received is a
            #list, return a list of each of its children elements,
            #traversed with the current state of the string
            return [traverse(x, *path) for x in obj]
        elif isinstance(obj, dict):
            #If the current state of the object received is a
            #dictionary, do the following...
            if isinstance(path[0], list) or isinstance(path[0], tuple):
                #If the current top item in the path is a list,
                #return a dictionary with keys to each of the
                #items in the list, each traversed recursively.
                for branch in path[0]:
                    if not isinstance(branch, basestring):
                        raise TraversalError(obj, path[0])
                return {name: traverse(obj[name], *path[1:], split=True) for name in path[0]}
            elif not isinstance(path[0], basestring):
                #If the key isn't a string (or a list; handled
                #previously), raise an exception.
                raise TraversalError(obj, path[0])
            elif path[0] == '\\*':
                #If the key is a wildcard, return a dict containing
                #each item, traversed down recursively.
                return {name: traverse(item, *path[1:], split=True) for name, item in obj.items()}
            elif path[0] in obj:
                #The individual key is in the current object;
                #traverse it and return the result.
                return traverse(obj[path[0]], *path[1:])
            else:
                #The individual key doesn't exist in the
                #current object; raise an error
                raise TraversalError(obj, path[0])
        else:
            #If the current object isn't either a list or
            #a dict, then do one of two things:
            if kwargs.get('split', False):
                #If the previously-recursed operation caused
                #a split in a dict, just return the object; it's
                #been specifically called out, but it isn't
                #possible to recurse further.
                return obj
            else:
                #The object can't be traversed, and we didn't
                #specifically call it out to do something
                #else with. Raise an exception.
                raise TraversalError(obj, path[0])
    else:
        #If there's no path left, then just return the
        #object that we received.
        return obj
790120
public Optional<DataType> get( Object tree, List<String> keys ) {

        if ( keys.size() != traversalLength ) {
            throw new TraversrException( "Traversal Path and number of keys mismatch, traversalLength:" + traversalLength + " numKeys:" + keys.size() );
        }

        return root.traverse( tree, TraversalStep.Operation.GET, keys.iterator(), null );
    }
135204
def traverse(self, predicate=lambda i, d: True,
                 prune=lambda i, d: False, depth=-1, branch_first=True,
                 visit_once=False, ignore_self=1):
        """"""
        return super(Tree, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self)
509284
function (nestedChildNodes, transaction, context, selfDebugID) // 0 in production and for roots
  {
    if (nestedChildNodes == null) {
      return null;
    }
    var childInstances = {};

    if (process.env.NODE_ENV !== 'production') {
      traverseAllChildren(nestedChildNodes, function (childInsts, child, name) {
        return instantiateChild(childInsts, child, name, selfDebugID);
      }, childInstances);
    } else {
      traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
    }
    return childInstances;
  }
811361
function traverse(value, cbs) {
  cbs = cbs || {};

  if (Array.isArray(value)) {
    if (cbs.beforeArray) value = cbs.beforeArray(value, cbs);

    value = value.map(function(v) {
      return traverse(v, cbs);
    });

    if (cbs.afterArray) value = cbs.afterArray(value, cbs);
  } else if (typeof value === 'object') {
    if (cbs.beforeObject) value = cbs.beforeObject(value, cbs);

    Object.keys(value).forEach(function(key) {
      value[key] = traverse(value[key], cbs);
    });

    if (cbs.afterObject) value = cbs.afterObject(value, cbs);
  }

  return value;
}
948167
function(obj, visitor, context, traversalStrategy) {
      traversalStrategy = traversalStrategy || this._traversalStrategy;
      walkImpl(obj, traversalStrategy, null, visitor, context);
    }
461607
protected DefaultMutableTreeNode getDataAsTree() {
        try {
            return (DefaultMutableTreeNode) MethodUtils.invokeMethod(view, "getDataAsTree", null);
        } catch (Exception e) {
            return null;
        }
    }
997230
private void traverseObjectDefinePropertiesCall(Node callNode, Scope scope) {
    // First child is Object.defineProperties or some equivalent of it.
    Node callee = callNode.getFirstChild();
    Node targetObject = callNode.getSecondChild();
    Node propertyDefinitions = targetObject.getNext();

    if ((targetObject.isName() || isNameDotPrototype(targetObject))
        && !NodeUtil.isExpressionResultUsed(callNode)) {
      // NOTE: Object.defineProperties() returns its first argument, so if its return value is used
      // that counts as a use of the targetObject.
      Node nameNode = targetObject.isName() ? targetObject : targetObject.getFirstChild();
      VarInfo varInfo = traverseNameNode(nameNode, scope);
      RemovableBuilder builder = new RemovableBuilder();
      // TODO(bradfordcsmith): Is it really necessary to traverse the callee
      // (aka. Object.defineProperties)?
      builder.addContinuation(new Continuation(callee, scope));
      if (NodeUtil.mayHaveSideEffects(propertyDefinitions, compiler)) {
        traverseNode(propertyDefinitions, scope);
      } else {
        builder.addContinuation(new Continuation(propertyDefinitions, scope));
      }
      varInfo.addRemovable(builder.buildClassSetupCall(callNode));
    } else {
      // TODO(bradfordcsmith): Is it really necessary to traverse the callee
      // (aka. Object.defineProperties)?
      traverseNode(callee, scope);
      traverseNode(targetObject, scope);
      traverseNode(propertyDefinitions, scope);
    }
  }