module T::Utils

def self.unwrap_nilable(type)

If so, returns the T::Types::Base of the something else. Otherwise, returns nil.
Give a type which is a subclass of T::Types::Base, determines if the type is a simple nilable type (union of NilClass and something else).
def self.unwrap_nilable(type)
  case type
  when T::Types::Union
    non_nil_types = type.types.reject {|t| t == Nilable::NIL_TYPE}
    if non_nil_types.length == 1
      non_nil_types.first
    else
      nil
    end
  else
    nil
  end
end