Hierarchical fragmentation and memoization in planning