private static boolean processPackagingElements(@NotNull JpsPackagingElement element,
                                                 @NotNull Processor<? super JpsPackagingElement> processor,
                                                 final Set<? super JpsPackagingElement> processed) {
    if (!processed.add(element)) {
      return false;
    }
    if (!processor.process(element)) {
      return false;
    }

    if (element instanceof JpsCompositePackagingElement) {
      for (JpsPackagingElement child : ((JpsCompositePackagingElement)element).getChildren()) {
        processPackagingElements(child, processor, processed);
      }
    }
    else if (element instanceof JpsComplexPackagingElement) {
      for (JpsPackagingElement child : ((JpsComplexPackagingElement)element).getSubstitution()) {
        processPackagingElements(child, processor, processed);
      }
    }
    return true;
  }
private static boolean processPackagingElements(@NotNull JpsPackagingElement element,
                                                 @NotNull Processor<? super JpsPackagingElement> processor,
                                                 final Set<? super JpsPackagingElement> processed)