question: public void expand ( int level ) { ArrayList < S2CellId > output = new ArrayList < S2CellId > ( ) ; long levelLsb = S2CellId . lowestOnBitForLevel ( level ) ; int i = size ( ) - 1 ; do { S2CellId id = cellId ( i ) ; if ( id . lowestOnBit ( ) < levelLsb ) { id = id . parent ( level ) ; while ( i > 0 && id . contains ( cellId ( i - 1 ) ) ) { -- i ; } } output . add ( id ) ; id . getAllNeighbors ( level , output ) ; } while ( -- i >= 0 ) ; initSwap ( output ) ; }
target:  Expands the cell union such that it contains all cells of the given level that are adjacent to any cell of the original union. Two cells are defined as adjacent if their boundaries have any points in common, i.e. most cells have 8 adjacent cells (not counting the cell itself). Note that the size of the output is exponential in "level". For example, if level == 20 and the input has a cell at level 10, there will be on the order of 4000 adjacent cells in the output. For most applications the Expand(min_fraction, min_distance) method below is easier to use.