def _strip_af(h, base, orbits, transversals, j):
 base_len = len(base)
 for i in range((j + 1), base_len):
  beta = h[base[i]]
  if (beta == base[i]):
   continue
  if (beta not in orbits[i]):
   return (h, (i + 1))
  u = transversals[i][beta]
  if (h == u):
   return (False, (base_len + 1))
  h = _af_rmul(_af_invert(u), h)
 return (h, (base_len + 1))

def _strip_af ( h , base , orbits , transversals , j ) : base_len = len ( base ) for i in range ( ( j + 1 ) , base_len ) : beta = h [ base [ i ] ] if ( beta == base [ i ] ) : continue if ( beta not in orbits [ i ] ) : return ( h , ( i + 1 ) ) u = transversals [ i ] [ beta ] if ( h == u ) : return ( False , ( base_len + 1 ) ) h = _af_rmul ( _af_invert ( u ) , h ) return ( h , ( base_len + 1 ) )
optimized _strip .