protected function filterInternal($set, $filterProperty, $negate)
    {
        if (is_object($set) && $set instanceof Collection) {
            $set = $set->toArray();
        }

        return array_filter($set, function ($element) use ($filterProperty, $negate) {
            $result = (boolean)ObjectAccess::getPropertyPath($element, $filterProperty);
            if ($negate) {
                $result = !$result;
            }

            return $result;
        });
    }