/** * @param array $nodes * @param callable $filter * @param callable $stopAt * @param int $options * @return array */ private function filterNodes(array $nodes, callable $filter = NULL, callable $stopAt = NULL, $options = 0) { $result = array(); foreach ($nodes as $index => $node) { list($isFilter, $isStopAt) = $this->getNodeStatus($node, $index, $filter, $stopAt); if ($isStopAt) { if ($isFilter && Constraints::hasOption($options, self::INCLUDE_STOP)) { $result[] = $node; } return $result; } elseif ($isFilter) { $result[] = $node; } } return $result; }