protected static function translateStack(&$stack, &$xpath)
{
do {
$matches_count = \preg_match_all(self::TOKEN, $xpath, $matches, \PREG_SET_ORDER);
for ($i = 0; $i < $matches_count; ++$i) {
list(, $type, $id) = $matches[$i];
$id = \intval($id);
list($replace, $groups) = $stack[$id];
foreach ($groups as $k => $v) {
$replace = \str_replace("\\{$k}", $v, $replace);
}
$xpath = \str_replace("{{$type}{$id}}", $replace, $xpath);
}
} while ($matches_count > 0);
}