Limit depth in displayHierarchyAsList, fixes #5399