learning macros in hierarchies