In one of my activities I insert some data to the Firebase database. In another activity I want to check if the child of the inserted data exists. If the key exists I want to get the root unique key.

**Problem:**
I have this database structure:

[![enter image description here](https://i.stack.imgur.com/xvWco.png)](https://i.stack.imgur.com/xvWco.png)

I want to check if the **username** child exists. If it exists I want to get the root key. Both the root unique key and the username node is marked with red.

**What I have done**

```
  //variable username is the actual username of the current user
    userRef.child(sharedPreferences.getString("school", null)).child("routes").orderByChild("username").equalTo(username).addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            for (DataSnapshot ds : dataSnapshot.getChildren()) {
                    String key=ds.getKey();
                    System.out.println("key" + key);
                }
        } 

```

But I don't now how to get inside the drivers node, and how to get the root unique key. Any ideas?