Пример #1
0
 public Father getPatriarch() {
   Father elder = father;
   while (elder != null) {
     if (elder == this) {
       throw new IllegalStateException("Impossible state"); // fail fast during infinite loop
     }
     elder = elder.getFather();
   }
   return elder;
 }