code: public static boolean isSingleton(Binding<?> binding) {
      do {
        boolean singleton = binding.acceptScopingVisitor(IS_SINGLETON_VISITOR);
        if (singleton) {
          return true;
        }
  
        if (binding instanceof LinkedBindingImpl) {
          LinkedBindingImpl<?> linkedBinding = (LinkedBindingImpl) binding;
          Injector injector = linkedBinding.getInjector();
          if (injector != null) {
            binding = injector.getBinding(linkedBinding.getLinkedKey());
            continue;
          }
        } else if (binding instanceof ExposedBinding) {
          ExposedBinding<?> exposedBinding = (ExposedBinding) binding;
          Injector injector = exposedBinding.getPrivateElements().getInjector();
          if (injector != null) {
            binding = injector.getBinding(exposedBinding.getKey());
            continue;
          }
        }
  
        return false;
      } while (true);
    }
docs: Returns true if {@code binding} is singleton-scoped. If the binding is a {@link
  com.google.inject.spi.LinkedKeyBinding linked key binding} and belongs to an injector (ie. it
  was retrieved via {@link Injector#getBinding Injector.getBinding()}), then this method will
  also true if the target binding is singleton-scoped.
  
  @since 3.0