@param Node[] $nodes
@return Node[]

$this->value = $value
↓
$this->value = $options['value']
183131
private function replaceParameterAssignWithOptionAssign(array $nodes, Param $param): array
    {
        foreach ($nodes as $expression) {
            if (! $expression instanceof Expression) {
                continue;
            }

            $node = $expression->expr;
            if (! $node instanceof Assign) {
                continue;
            }

            $variableName = $this->getName($node->var);
            if ($variableName === null) {
                continue;
            }

            if ($node->expr instanceof Variable) {
                $node->expr = new ArrayDimFetch($param->var, new String_($variableName));
            }
        }

        return $nodes;
    }
447512
public function filterNodeDepth($nodes, $depth)
    {
        if(empty($nodes) || $depth === 0)
        {
            return array();
        }

        $newNodes = array();
        $stack = array();
        $level = 0;

        foreach($nodes as $node)
        {
            $parent = end($stack);
            while($parent && $node->getLeftValue() > $parent->getRightValue())
            {
                array_pop($stack);
                $parent = end($stack);
                $level--;
            }

            if($level < $depth)
            {
                $newNodes[] = $node;
            }

            if(($node->getRightValue() - $node->getLeftValue()) > 1)
            {
                array_push($stack, $node);
                $level++;
            }
        }

        return $newNodes;
    }
1108007
private function loadValues(\DOMXPath $xpath, \DOMNode $node, $keys, $prefix = '@')
    {
        $result = [];

        foreach ($keys as $key) {
            $result[$key] = $this->getValueFromXPath($prefix . $key, $xpath, $node);
        }

        return $result;
    }
1266985
private function arrayDeference(Node $node) {
    while ($this->currentType === '[') {
      $n = $node;
      $node = new ArrayLookupNode();
      $node->addChild($n, 'array');
      $this->dimOffset($node);
    }
    return $node;
  }
1331937
private function buildArrayFromNode(SimpleXMLElement $node): array
    {
        $array = [];
        foreach ($node->children() as $child) {
            if ((string) $child !== '') {
                $array[] = (string) $child;
            }
        }

        return $array;
    }
479279
protected function filterList(array $nodes = array(), array $rules = array())
  {
    if(!empty($rules))
    {
      foreach($nodes as $node)
      {
        if(!$node instanceof Node) continue;

        $props = $node->getInfo(FALSE);
        $props = array_intersect_key($props, $rules);

        foreach($props as $key => $val)
        {
          if($val instanceof Str)
          {
            $match = $val->contains($rules[$key], TRUE);
          }
          else
          {
            $match = $val == $rules[$key];
          }

          if($match === FALSE)
          {
            unset($nodes[$node->getId()]);
          }
        }
      }
    }

    return $nodes;
  }
586993
public function getListNodes($nodes)
    {
        $xPath = new DOMXPath($this->getDomXml());
        $nodeList = $xPath->query("//SUBMENU[@cl='" . implode("' or @cl='", $nodes) . "']");

        return ($nodeList->length) ? $nodeList : null;
    }
1143480
public function discardNodes(array $nodes)
    {
        $discardedNodeIdentifiers = [];
        foreach ($nodes as $node) {
            $this->doDiscardNode($node, $discardedNodeIdentifiers);
        }
    }
767958
protected function seek(array $nodes, array $rule, array $options): array
    {
        // XPath index
        if (array_key_exists('tag', $rule) &&
            array_key_exists('key', $rule) &&
            is_numeric($rule['key'])
        ) {
            $count = 0;
            /** @var AbstractNode $node */
            foreach ($nodes as $node) {
                if ($rule['tag'] == '*' ||
                    $rule['tag'] == $node->getTag()->name()
                ) {
                    ++$count;
                    if ($count == $rule['key']) {
                        // found the node we wanted
                        return [$node];
                    }
                }
            }

            return [];
        }

        $options = $this->flattenOptions($options);

        $return = [];
        /** @var InnerNode $node */
        foreach ($nodes as $node) {
            // check if we are a leaf
            if ($node instanceof LeafNode ||
                ! $node->hasChildren()
            ) {
                continue;
            }

            $children = [];
            $child    = $node->firstChild();
            while ( ! is_null($child)) {
                // wild card, grab all
                if ($rule['tag'] == '*' && is_null($rule['key'])) {
                    $return[] = $child;
                    $child = $this->getNextChild($node, $child);
                    continue;
                }

                $pass = $this->checkTag($rule, $child);
                if ($pass && ! is_null($rule['key'])) {
                    $pass = $this->checkKey($rule, $child);
                }
                if ($pass && ! is_null($rule['key']) &&
                    ! is_null($rule['value']) && $rule['value'] != '*'
                ) {
                    $pass = $this->checkComparison($rule, $child);
                }

                if ($pass) {
                    // it passed all checks
                    $return[] = $child;
                } else {
                    // this child failed to be matched
                    if ($child instanceof InnerNode &&
                        $child->hasChildren()
                    ) {
                        // we still want to check its children
                        $children[] = $child;
                    }
                }

                $child = $this->getNextChild($node, $child);
            }

            if (( ! isset($options['checkGrandChildren']) ||
                    $options['checkGrandChildren'])
                && count($children) > 0
            ) {
                // we have children that failed but are not leaves.
                $matches = $this->seek($children, $rule, $options);
                foreach ($matches as $match) {
                    $return[] = $match;
                }
            }
        }

        return $return;
    }
1341888
public function getNodesTree($nodes, $parentId)
    {
        return collect($nodes)->filter(function ($value) use ($parentId) {
            if (isset($value['parent_id'])) {
                if ($value['parent_id'] == $parentId) {
                    return true;
                }

                return false;
            }

            return true;
        })->mapWithKeys(function ($value, $key) use ($nodes) {
            $data = [
                'id'    => (string) $value['id'],
                'label' => $value['label'],
            ];

            if (isset($value['parent_id'])) {
                $children = $this->getNodesTree($nodes, $value['id']);
                if ($children->isNotEmpty()) {
                    $data['children'] = $children;
                }
            }

            return [
                $key => $data,
            ];
        })->values();
    }
40267
public function replaceWith($nodes) {
    $first = TRUE;
    foreach ($this->nodes as $node) {
      if (!$first) {
        if (is_array($nodes)) {
          $nodes = new NodeCollection($nodes, FALSE);
        }
        $nodes = clone $nodes;
      }
      $node->replaceWith($nodes);
      $first = FALSE;
    }
    return $this;
  }
779575
private function extractModifiedVariableNames(array $nodes)
    {
        $modifiedNames = array();
        foreach ($nodes as $node) {
            if (!$node) {
                continue;
            }

            $variableNameNode = $node;
            if ($node instanceof Node\Arg) {
                $variableNameNode = $node->value;
            }

            if ($node instanceof Node\Expr\ArrayDimFetch) {
                $variableNameNode = $node->var;
            }

            if (!($variableNameNode instanceof Node\Expr\Variable)) {
                continue;
            }

            $variableName = $this->convertVariableNameToString($variableNameNode);
            $modifiedNames[] = $variableName;
        }

        return array_unique($modifiedNames);
    }
505033
private function addImplicitReturn(array $nodes)
    {
        // If nodes is empty, it can't have a return value.
        if (empty($nodes)) {
            return [new Return_(NoReturnValue::create())];
        }

        $last = \end($nodes);

        // Special case a few types of statements to add an implicit return
        // value (even though they technically don't have any return value)
        // because showing a return value in these instances is useful and not
        // very surprising.
        if ($last instanceof If_) {
            $last->stmts = $this->addImplicitReturn($last->stmts);

            foreach ($last->elseifs as $elseif) {
                $elseif->stmts = $this->addImplicitReturn($elseif->stmts);
            }

            if ($last->else) {
                $last->else->stmts = $this->addImplicitReturn($last->else->stmts);
            }
        } elseif ($last instanceof Switch_) {
            foreach ($last->cases as $case) {
                // only add an implicit return to cases which end in break
                $caseLast = \end($case->stmts);
                if ($caseLast instanceof Break_) {
                    $case->stmts = $this->addImplicitReturn(\array_slice($case->stmts, 0, -1));
                    $case->stmts[] = $caseLast;
                }
            }
        } elseif ($last instanceof Expr && !($last instanceof Exit_)) {
            // @codeCoverageIgnoreStart
            $nodes[\count($nodes) - 1] = new Return_($last, [
                'startLine' => $last->getLine(),
                'endLine'   => $last->getLine(),
            ]);
        // @codeCoverageIgnoreEnd
        } elseif ($last instanceof Expression && !($last->expr instanceof Exit_)) {
            // For PHP Parser 4.x
            $nodes[\count($nodes) - 1] = new Return_($last->expr, [
                'startLine' => $last->getLine(),
                'endLine'   => $last->getLine(),
            ]);
        } elseif ($last instanceof Namespace_) {
            $last->stmts = $this->addImplicitReturn($last->stmts);
        }

        // Return a "no return value" for all non-expression statements, so that
        // PsySH can suppress the `null` that `eval()` returns otherwise.
        //
        // Note that statements special cased above (if/elseif/else, switch)
        // _might_ implicitly return a value before this catch-all return is
        // reached.
        //
        // We're not adding a fallback return after namespace statements,
        // because code outside namespace statements doesn't really work, and
        // there's already an implicit return in the namespace statement anyway.
        if (self::isNonExpressionStmt($last)) {
            $nodes[] = new Return_(NoReturnValue::create());
        }

        return $nodes;
    }
274764
private function prepareNodesTree(
        $nodes,
        $webspaceKey,
        $languageCode,
        $complete = true,
        $excludeGhosts = false,
        $maxDepth = 1,
        $currentDepth = 0
    ) {
        ++$currentDepth;

        $results = [];
        foreach ($nodes as $node) {
            $result = $this->prepareNode($node, $webspaceKey, $languageCode, 1, $complete, $excludeGhosts);
            if (null !== $maxDepth &&
                $currentDepth < $maxDepth &&
                $node->getHasChildren() &&
                null != $node->getChildren()
            ) {
                $result['_embedded']['nodes'] = $this->prepareNodesTree(
                    $node->getChildren(),
                    $webspaceKey,
                    $languageCode,
                    $complete,
                    $excludeGhosts,
                    $maxDepth,
                    $currentDepth
                );
            }
            $results[] = $result;
        }

        return $results;
    }
560988
public function merge($elements = []): NodeList {
        if (!is_array($elements)) {
            $elements = $elements->toArray();
        }

        return $this->newNodeList(array_merge($this->toArray(), $elements));
    }
208312
private static function _nodeToArray($node)
    {
        $type = null;
        if ($node instanceof DOMElement) {
            $type = $node->getAttribute('type');
        }

        switch($type) {
        case 'array':
            $array = [];
            foreach ($node->childNodes as $child) {
                $value = self::_nodeToValue($child);
                if ($value !== null) {
                    $array[] = $value;
                }
            }
            return $array;
        case 'collection':
            $collection = [];
            foreach ($node->childNodes as $child) {
                $value = self::_nodetoValue($child);
                if ($value !== null) {
                    if (!isset($collection[$child->nodeName])) {
                        $collection[$child->nodeName] = [];
                    }
                    $collection[$child->nodeName][] = self::_nodeToValue($child);
                }
            }
            return $collection;
        default:
            $values = [];
            if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) {
                return $node->childNodes->item(0)->nodeValue;
            } else {
                foreach ($node->childNodes as $child) {
                    if (!$child instanceof DOMText) {
                        $values[$child->nodeName] = self::_nodeToValue($child);
                    }
                }
                return $values;
            }
        }
    }
1173785
private function createSubCrawler($nodes)
    {
        $crawler = new static($nodes, $this->uri, $this->baseHref);
        $crawler->isHtml = $this->isHtml;
        $crawler->document = $this->document;
        $crawler->namespaces = $this->namespaces;
        $crawler->html5Parser = $this->html5Parser;

        return $crawler;
    }