In this paper an approach for hierarchical time series forecasting based on State Space modelling is proposed. Previous developments provide solutions to the hierarchical forecasting problem by algebra manipulations based on forecasts produced by independent models for each time series involved in the hierarchy. The solutions produce optimal reconciled forecasts for each individual forecast horizon, but the link along time that is implied by the dynamics of the models is completely ignored. Therefore, the novel approach in this paper improves upon past research at least in two key points. Firstly, the algebra is already encoded in the State Space system and the Kalman Filter algorithm, giving an elegant and clean solution to the problem. Secondly, the State Space approach is optimal both across the hierarchy, as expected, but also along time, something missing in past developments. In addition, the present approach provides an unified treatment of top-down, bottom-up, middle-out and reconciled approaches reported in the literature; it generalizes the optimization of hierarchies by proposing combined hierarchies which integrate the previous categories at different segments of the hierarchy; and it allows for multiple hierarchies to be simultaneously adjusted. The approach is assessed by comparing its forecasting performance to the existing methods, through simulations and using real data of a Spanish grocery retailer.