question: public Space prune ( Space prefix ) throws ScopeException { Space x = this ; ArrayList < Space > stack = new ArrayList < > ( ) ; while ( x != null && ! x . equals ( prefix ) ) { stack . add ( 0 , x ) ; x = x . getParent ( ) ; } if ( x == null ) { throw new ScopeException ( "cannot prune distinct spaces" ) ; } else { Space result = new Space ( universe , x . getDomain ( ) ) ; for ( Space space : stack ) { result = result . S ( space . getRelation ( ) ) ; } return result ; } }
target:  prune this space using the given prefix