def treefindallby(subtree, value, by="node_id"):
    """
    Returns all node in `subtree` that have attribute `by` equal to `value`.
    """
    results = []
    if by in subtree and subtree[by] == value:
        results.append(subtree)
    if 'children' in subtree:
        for child in subtree['children']:
            child_results = treefindallby(child, value, by=by)
            results.extend(child_results)
    return results