Код:
List<String> getClauses() {
List<String> result = new ArrayList<>();
if ( words.size() == 0 ) {
result.add(root);
} else {
for ( String word : words ) {
Node n = new Node(word, words);
for ( String child : n.getClauses() ) {
result.add(root + " " + child);
}
}
}
return result;
}