public function resolve(NodeContract $node)
    {
        $children = $node->getChildren();

        if (count($children) > 0) {
            $this->resolve($node->getChildByIndex(0));

            $value = '';
            $positions = [];
            foreach ($node->getChildren() as $child) {
                if ($child instanceof Nodes\TextNode || $child instanceof Nodes\KeyNode) {
                    $value .= ' '.$child->getValue();
                    $p = array_fill(0, strlen(' '.$child->getValue()), $child->getIndex());
                    $positions = array_merge($positions, $p);
                }
            }

            foreach ($this->regex as $regex) {
                preg_match($regex, $value, $match, PREG_OFFSET_CAPTURE);

                if ($match) {
                    $new_node = new $this->node();

                    $start = $match[0][1];
                    $length = strlen($match[0][0]);

                    $this->groupNode($node, $new_node, $start, $start + $length, $positions);
                    $this->resolveRelationsNode($node, $new_node);

                    // Search for another match in this node.
                    return $this->resolve($node->getParent());
                }
            }
        }

        return $node->next() !== null ? $this->resolve($node->next()) : null;
    }