Creating a nested melodic representation: competition and cooperation among bottom-up and top-down Gestalt principles