def kchainbasis(h, k):
    """
    Compute the set of k dimensional cells in the abstract simplicial 
    complex associated with the hypergraph. 

    Parameters
    ----------
    h : hnx.Hypergraph
    k : int
        dimension of cell
    
    Returns
    -------
     : list
        an ordered list of kchains represented as tuples of length k+1

    See also
    --------
    hnx.hypergraph.toplexes

    Notes
    -----
    - Method works best if h is simple [Berge], i.e. no edge contains another and there are no duplicate edges (toplexes). 
    - Hypergraph node uids must be sortable.

    """
    import itertools as it
    kchains = set()
    for e in h.edges():
        if len(e) == k + 1:
            kchains.add(tuple(sorted(e.uidset)))
        elif len(e) > k + 1:
            kchains.update(set(it.combinations(sorted(e.uidset), k + 1)))
    return sorted(list(kchains))
