public function evaluate(FlowQuery $flowQuery, array $arguments)
{
$output = array();
$outputNodePaths = array();
/** @var NodeInterface $contextNode */
foreach ($flowQuery->getContext() as $contextNode) {
$outputNodePaths[$contextNode->getPath()] = true;
}
foreach ($flowQuery->getContext() as $contextNode) {
$parentNode = $contextNode->getParent();
if ($parentNode instanceof NodeInterface) {
foreach ($parentNode->getChildNodes() as $childNode) {
if (!isset($outputNodePaths[$childNode->getPath()])) {
$output[] = $childNode;
$outputNodePaths[$childNode->getPath()] = true;
}
}
}
}
$flowQuery->setContext($output);
if (isset($arguments[0]) && !empty($arguments[0])) {
$flowQuery->pushOperation('filter', $arguments);
}
}