nodes: 0, module; 1, function_definition; 2, function_name:layer_sort; 3, parameters; 4, block; 5, identifier:hmap; 6, expression_statement; 7, expression_statement; 8, for_statement; 9, return_statement; 10, comment:"""
     Find a global ordering for layers in a HoloMap of CompositeOverlay
     types.
     """; 11, assignment; 12, identifier:o; 13, identifier:hmap; 14, block; 15, list_comprehension; 16, identifier:orderings; 17, dictionary; 18, expression_statement; 19, if_statement; 20, identifier:i; 21, for_in_clause; 22, for_in_clause; 23, assignment; 24, boolean_operator; 25, block; 26, else_clause; 27, identifier:g; 28, call; 29, identifier:i; 30, call; 31, identifier:okeys; 32, list_comprehension; 33, comparison_operator:len(okeys) == 1; 34, not_operator; 35, expression_statement; 36, block; 37, identifier:sort_topologically; 38, argument_list; 39, identifier:sorted; 40, argument_list; 41, call; 42, for_in_clause; 43, call; 44, integer:1; 45, comparison_operator:okeys[0] in orderings; 46, assignment; 47, expression_statement; 48, identifier:orderings; 49, identifier:g; 50, identifier:get_overlay_spec; 51, argument_list; 52, pattern_list; 53, call; 54, identifier:len; 55, argument_list; 56, subscript; 57, identifier:orderings; 58, subscript; 59, list; 60, call; 61, identifier:o; 62, identifier:k; 63, identifier:v; 64, identifier:k; 65, identifier:v; 66, attribute; 67, argument_list; 68, identifier:okeys; 69, identifier:okeys; 70, integer:0; 71, identifier:orderings; 72, subscript; 73, attribute; 74, argument_list; 75, attribute; 76, identifier:items; 77, identifier:okeys; 78, integer:0; 79, identifier:orderings; 80, identifier:update; 81, dictionary_comprehension; 82, identifier:o; 83, identifier:data; 84, pair; 85, for_in_clause; 86, identifier:k; 87, conditional_expression:[] if k == v else [v]; 88, pattern_list; 89, call; 90, list; 91, comparison_operator:k == v; 92, list; 93, identifier:k; 94, identifier:v; 95, identifier:zip; 96, argument_list; 97, identifier:k; 98, identifier:v; 99, identifier:v; 100, subscript; 101, identifier:okeys; 102, identifier:okeys; 103, slice; 104, integer:1
code: def layer_sort(hmap):
     """
     Find a global ordering for layers in a HoloMap of CompositeOverlay
     types.
     """
     orderings = {}
     for o in hmap:
        okeys = [get_overlay_spec(o, k, v) for k, v in o.data.items()]
        if len(okeys) == 1 and not okeys[0] in orderings:
           orderings[okeys[0]] = []
        else:
           orderings.update({k: [] if k == v else [v] for k, v in zip(okeys[1:], okeys)})
     return [i for g in sort_topologically(orderings) for i in sorted(g)]