code: @Nullable
    private static ObjectType instanceTypeFor(JSType type) {
      if (type == null) {
        return null;
      } else if (type.isUnionType()) {
        return null; // A union has no meaningful instance type.
      } else if (type.isInstanceType() || type.isUnknownType()) {
        return type.toMaybeObjectType();
      } else if (type.isConstructor() || type.isInterface()) {
        return type.toMaybeFunctionType().getInstanceType();
      } else if (type.isFunctionType()) {
        return null; // Functions that aren't ctors or interfaces have no instance type.
      } else if (type.isFunctionPrototypeType()) {
        return instanceTypeFor(type.toMaybeObjectType().getOwnerFunction());
      }
  
      return type.toMaybeObjectType();
    }
docs: Returns the type that best represents the instance type for {@code type}.
  
  <ul>
  <li>Prototype type => The instance type having that prototype
  <li>Instance type => The type
  <li>Constructor type => The type that constructor instantiates
  <li>Object-literal type => The type
  </ul>