Do you mean the initial upstream dataset for a specific node in the flow? i.e. in this example if you selected the dataset "Orders_by_Country_Category" for example, you would want the "Orders" and "Customers" folders returned?
You can recurse through the flow using the flow API, to get all source items for any given "search node". Here is an example:
def get_predessor(node, roots):
if len(node['predecessors']) < 1:
for node_key in node['predecessors']:
child_node = graph.nodes[node_key]
roots = 
client = dataiku.api_client()
# gets our current project graph
project = client.get_default_project()
flow = project.get_flow()
graph = flow.get_graph()
# replace with your search dataset/recipe ID
search_item = 'Orders_by_Country_Category'
search_node = graph.nodes[search_item]
# call our function to recurse through the graph and return all roots of the given search node
n = get_predessor(search_node, roots)
For the example flow above this returns the folder IDs for the two source folders in my flow:
Let me know if you have any questions about this!