Tuning capillary flow in porous media with hierarchical structures