private function doTraverse($node, $path = array())
    {
        foreach ($node as $name => $value) {
            $path[] = $name;
            $value = $this->doVisit($path, $value, self::BEFORE);

            if (is_array($value)) {
                $value = $this->doTraverse($value, $path);
            }

            $value = $this->doVisit($path, $value, self::AFTER);
            $node[$name] = $value;
            array_pop($path);
        }

        return $node;
    }