protected Binding findBinding(
      final Binding[] bindings, final String componentName, final Interface itf) {
    if (isCollection(itf)) {
      final int noe = getNumberOfElement(itf);
      if (noe == -1) {
        return findBinding(bindings, componentName, itf.getName(), -1);
      } else {
        // the interface is a collection interface
        // first checks if a global binding is defined on the interface

        Binding b = findBinding(bindings, componentName, itf.getName(), -1);
        if (b != null) {
          // there is a global binding for the defined interface
          return b;
        }

        // checks that every interfaces of the collection are bound
        assert noe > 0;
        for (int i = 0; i < noe; i++) {
          b = findBinding(bindings, componentName, itf.getName(), i);
          if (b == null) return null;
        }
        return b;
      }
    } else {
      return findBinding(bindings, componentName, itf.getName(), -1);
    }
  }
  protected void checkUnboundInterfaces(
      final ComponentContainer container, final Map<Object, Object> context) throws ADLException {
    final Binding[] bindings =
        (container instanceof BindingContainer)
            ? ((BindingContainer) container).getBindings()
            : new Binding[0];

    // first check internal client interfaces
    if (container instanceof InternalInterfaceContainer) {
      for (final Interface itf : ((InternalInterfaceContainer) container).getInternalInterfaces()) {
        if (isClient(itf) && isMandatory(itf)) {
          if (findBinding(bindings, THIS_COMPONENT, itf) == null)
            errorManagerItf.logError(
                BindingErrors.UNBOUND_COMPOSITE_SERVER_INTERFACE,
                container,
                itf.getName(),
                ((Definition) container).getName());
        }
      }
    }

    // then check client interfaces of sub components
    for (final Component subComponent : container.getComponents()) {
      final Definition subCompDef =
          getResolvedComponentDefinition(subComponent, recursiveLoaderItf, context);
      assert subCompDef != null;
      if (ASTHelper.isUnresolvedDefinitionNode(subCompDef)) continue;

      if (subCompDef instanceof InterfaceContainer) {
        for (final Interface itf : ((InterfaceContainer) subCompDef).getInterfaces()) {
          if (isClient(itf) && isMandatory(itf)) {
            if (findBinding(bindings, subComponent.getName(), itf) == null)
              errorManagerItf.logError(
                  BindingErrors.UNBOUND_CLIENT_INTERFACE,
                  subComponent,
                  itf.getName(),
                  subComponent.getName());
          }
        }
      }
    }
  }