private function clickButton(\DOMNode $node)
    {
        $formParams = [];
        $buttonName = (string)$node->getAttribute('name');
        $buttonValue = $node->getAttribute('value');

        if ($buttonName !== '' && $buttonValue !== null) {
            $formParams = [$buttonName => $buttonValue];
        }

        while ($node->parentNode !== null) {
            $node = $node->parentNode;
            if (!isset($node->tagName)) {
                // this is the top most node, it has no parent either
                break;
            }
            if ($node->tagName === 'a') {
                $this->openHrefFromDomNode($node);
                return true;
            } elseif ($node->tagName === 'form') {
                $this->proceedSubmitForm(
                    new Crawler($node, $this->getAbsoluteUrlFor($this->_getCurrentUri()), $this->getBaseUrl()),
                    $formParams
                );
                return true;
            }
        }
        codecept_debug('Button is not inside a link or a form');
        return false;
    }