code: public static <T> Set<T> toSet(Iterable<T> iterable)
     {
        if (iterable == null)
        {
           return null;
        }
        else if (iterable instanceof Set)
        {
           return (Set<T>) iterable;
        }
        else
        {
           Set<T> list = new LinkedHashSet<>();
           for (T obj : iterable)
           {
              list.add(obj);
           }
           return list;
        }
     }
docs: Converts an {@link Iterable} to a {@link Set}