function unique($key, $options = \SORT_REGULAR) {
        if($key === null) {
            return (new self(\array_unique($this->data, $options)));
        }
        
        $exists = array();
        return $this->filter(function ($item) use ($key, &$exists) {
            if(\is_array($item)) {
                if(!isset($item[$key])) {
                    throw new \BadMethodCallException('Specified key "'.$key.'" does not exist on array');
                }
                
                $id = $item[$key];
            } elseif(\is_object($item)) {
                if(!isset($item->$key)) {
                    throw new \BadMethodCallException('Specified key "'.$key.'" does not exist on object');
                }
                
                $id = $item->$key;
            } else {
                $id = $item;
            }
            
            if(\in_array($id, $exists, true)) {
                return false;
            }
            
            $exists[] = $id;
            return true;
        });
    }