hat, pulls (something) out of the

(informal) gets (something) as if by magic; invents or imagines (something).