public function hasKey($key, $recursive = TRUE) {
    if (!($key instanceof ExpressionNode) && !is_scalar($key)) {
      throw new \InvalidArgumentException();
    }

    $keys = $this->getKeys($recursive);
    if (is_scalar($key)) {
      return $keys
        ->filter(Filter::isInstanceOf('\Pharborist\Types\ScalarNode'))
        ->is(function(ScalarNode $node) use ($key) {
          return $node->toValue() === $key;
        });
    }
    else {
      return $keys
        ->is(function(ExpressionNode $expr) use ($key) {
          return $expr->getText() === $key->getText();
        });
    }
  }