get_hierarchy_tree(): fix behavior for filtered graphs

This fixes issue #737
3 jobs for master in 41 minutes and 49 seconds (queued for 1 second)