private List<ClassName> enclosingClasses() {
    List<ClassName> result = new ArrayList<>();
    for (ClassName c = this; c != null; c = c.enclosingClassName) {
      result.add(c);
    }
    Collections.reverse(result);
    return result;
  }
private List < ClassName > enclosingClasses ( ) { List < ClassName > result = new ArrayList < > ( ) ; for ( ClassName c = this ; c != null ; c = c . enclosingClassName ) { result . add ( c ) ; } Collections . reverse ( result ) ; return result ; }
Returns all enclosing classes in this, outermost first.