private static Stream<Function> extractDataAtoms(Collection<? extends Term> atoms) {
        return atoms.stream()
                .filter(t -> t instanceof Function)
                .map(f -> (Function) f)
                .flatMap(a -> {
                    if (a.isDataFunction()) {
                        return Stream.of(a);
                    }
                    else if (a.isAlgebraFunction()) {
                        return extractDataAtoms(a.getTerms());
                    }
                    else {
                        return Stream.empty();
                    }
                });
    }
private static Stream < Function > extractDataAtoms ( Collection < ? extends Term > atoms ) { return atoms . stream ( ) . filter ( t -> t instanceof Function ) . map ( f -> ( Function ) f ) . flatMap ( a -> { if ( a . isDataFunction ( ) ) { return Stream . of ( a ) ; } else if ( a . isAlgebraFunction ( ) ) { return extractDataAtoms ( a . getTerms ( ) ) ; } else { return Stream . empty ( ) ; } } ) ; }
Extracts all the data atoms (without preserving the algebraic structure)