title: Firebase query in tree with depth and multiple children
body: <p>I have a problem regarding querying the firebase database using a value and getting the specific node. My schema is shown here:</p>
  
  <p><a href="https://i.stack.imgur.com/bhk0A.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bhk0A.png" alt="Firebase schema"></a></p>
  
  <p>In my schema 'workLocations' belongs to an 'excavationWorks', and 'excavationWorks' belongs to an 'excavationLists'. </p>
  
  <p>That means that the path to a specific workLocation is <code>excavationLists/excavationWorks/workLocations/(specific workLocation)</code></p>
  
  <p>The problem that I have is that I want to query the workLocations node by the location value (let's say London) and get the parent node (the red circled key which is the key of the specific workLocation). </p>
  
  <p>I have search and read many posts but I haven't managed to make it work.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code> DatabaseReference reference = FirebaseDatabase.getInstance().getReference();
  
   Query query = reference.child("workLocations").orderByChild("location").equalTo("London");
   query.addListenerForSingleValueEvent(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
                  for (DataSnapshot workLoc : dataSnapshot.getChildren()) {
                      // do something with the individual "issues"
                      Log.d(TAG, workLoc.getKey());
                  }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
  
          }
      });
  </code></pre>
  
  <p>Thank you</p>