Automatic derivation of hierarchical representations for flow-based functional models