shell – Move folders containing files with extension

Example of folder structure:

Tree test tree
.
├── testflac1
│ ├── track1.flac
│ ├── track2.flac
3. └── track3.flac
├── testflac2
│ ├── track1.flac
│ ├── track2.flac
3. └── track3.flac
├── testflac3
│ ├── track1.flac
│ ├── track2.flac
3. └── track3.flac
├── testmp31
│ ├── track1.mp3
2. ├── track2.mp3
│ └── track3.mp3
├── testmp32
│ ├── track1.mp3
2. ├── track2.mp3
│ └── track3.mp3
└── testmp33
├── track1.mp3
├── track2.mp3
└── track3.mp3

And the goal would be to move folders containing an extension into a directory, like ~ / test [FLAC] and others containing mp3 extension to ~ / test [MP3]. I tried to do that with findbut it only allowed me to move files themselves, without keeping the folder structure.