public static List<Import> importsOf(HasImports<?> root) {
        final List<Import> found = new ArrayList<>(root.getImports());

        if (root instanceof HasClasses) {
            final HasClasses<?> classes = (HasClasses<?>) root;
            classes.getClasses().forEach(clazz -> found.addAll(importsOf(clazz)));
        }

        if (root instanceof HasFields) {
            final HasFields<?> classes = (HasFields<?>) root;
            classes.getFields().forEach(field -> found.addAll(importsOf(field)));
        }

        if (root instanceof HasMethods) {
            final HasMethods<?> classes = (HasMethods<?>) root;
            classes.getMethods().forEach(field -> found.addAll(importsOf(field)));
        }

        if (root instanceof HasConstructors) {
            final HasConstructors<?> classes = (HasConstructors<?>) root;
            classes.getConstructors().forEach(constr -> found.addAll(importsOf(constr)));
        }

        if (root instanceof HasInitializers) {
            final HasInitializers<?> classes = (HasInitializers<?>) root;
            classes.getInitializers().forEach(init -> found.addAll(importsOf(init)));
        }

        if (root instanceof HasJavadoc) {
            final HasJavadoc<?> classes = (HasJavadoc<?>) root;
            classes.getJavadoc().ifPresent(doc -> found.addAll(importsOf(doc)));
        }

        return found;
    }
Returns a list of all the imports of the specified model by traversing
the entire tree.

@param root  the root to start at (usually the {@link File})
@return      the list of imports
common-parent/codegen/src/main/java/com/speedment/common/codegen/internal/util/ModelTreeUtil.java