def get_roots(pred_calls, sort_key = str):
    """Returns list of all roots of the given predicate calls.

    >>> aststs = functools.partial(ast, sts)
    >>> preds = list(map(aststs, [sl.tree("x"), sl.list("h"), sl.tree("a"), sl.list.seg("h", "t")]))
    >>> get_roots(preds)
    [a, h, x]
    >>> get_roots(preds, struct_arity_key(preds))
    [h, a, x]

    """
    unique_roots = set(pred.root for pred in pred_calls)
    return sorted(unique_roots, key = sort_key)