diff --git a/yt/utilities/hierarchy_inspection.py b/yt/utilities/hierarchy_inspection.py index 7e62ed1684f..8a2e0aae92f 100644 --- a/yt/utilities/hierarchy_inspection.py +++ b/yt/utilities/hierarchy_inspection.py @@ -39,4 +39,4 @@ def find_lowest_subclasses(candidates: List[Type]) -> List[Type]: count = reduce(lambda x, y: x + y, counters) - return [x for x in count.keys() if count[x] == 1] + return [x for x in candidates if count[x] == 1] diff --git a/yt/utilities/tests/test_hierarchy_inspection.py b/yt/utilities/tests/test_hierarchy_inspection.py index 8f7d7510e61..c5d36f90952 100644 --- a/yt/utilities/tests/test_hierarchy_inspection.py +++ b/yt/utilities/tests/test_hierarchy_inspection.py @@ -55,3 +55,9 @@ def test_diverging_tree(): result = find_lowest_subclasses([level1, level2, level3, level1a]) assert len(result) == 2 assert level1a in result and level3 in result + + +def test_without_parents(): + result = find_lowest_subclasses([level1, level3]) + assert len(result) == 1 + assert level3 in result