def get_leaves(hdic):
    """
    Give it a dictionary and it returns a list of all leaf nodes
    Input : hdic - a hierarchical dictionary
    Output: leaves - a list of leaf nodes
    """
    leaves = []
    for key, value in hdic.iteritems():
        if isinstance(value, dict):
            # Descend through the dictionary stack
            leaves += get_leaves(value)
        else:
            leaves += [value]
    return leaves