Automatic Discovery and Transfer of Task Hierarchies in Reinforcement Learning