Online Structure Learning for Feed-Forward and Recurrent Sum-Product Networks