def find_drum_group_device(track_or_chain):
 instrument = find_if((lambda d: (d.type == Live.Device.DeviceType.instrument)), track_or_chain.devices)
 if instrument:
  if instrument.can_have_drum_pads:
   return instrument
  elif instrument.can_have_chains:
   return find_if(bool, imap(find_drum_group_device, instrument.chains))

def find_drum_group_device ( track_or_chain ) : instrument = find_if ( ( lambda d : ( d . type == Live . Device . DeviceType . instrument ) ) , track_or_chain . devices ) if instrument : if instrument . can_have_drum_pads : return instrument elif instrument . can_have_chains : return find_if ( bool , imap ( find_drum_group_device , instrument . chains ) )
looks up recursively for a drum_group device in the track .