ApkPackage { public boolean doSubpackagesHaveClasses() { for (ApkPackage subpackage : getSubpackages()) { if (!subpackage.getClasses().isEmpty()) { return true; } } return false; } ApkPackage(@NotNull String name, @Nullable ApkPackage parent); @NotNull Collection<ApkPackage> getSubpackages(); @Nullable ApkPackage findSubpackage(@NotNull String name); @NotNull Collection<ApkClass> getClasses(); @Nullable ApkClass findClass(@NotNull String name); @Nullable ApkPackage getParent(); @NotNull ApkPackage addSubpackage(@NotNull String name); @NotNull ApkClass addClass(@NotNull String name); @NotNull String getName(); @NotNull String getFqn(); boolean doSubpackagesHaveClasses(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void doSubpackagesHaveClasses() { ApkPackage aPackage = new ApkPackage("a", null); ApkPackage bPackage = aPackage.addSubpackage("b"); assertFalse(aPackage.doSubpackagesHaveClasses()); assertFalse(bPackage.doSubpackagesHaveClasses()); bPackage.addClass("Class1"); assertTrue(aPackage.doSubpackagesHaveClasses()); assertFalse(bPackage.doSubpackagesHaveClasses()); }