Detecting full loop paths

I want to find unique combinations starting from a node and ending at the same node.

Say I have 5 node types : A, B, C, D, E each having a literal name and the following predicates connect the nodes - AB, AC, BD, CD, DE with reverse edges. I would like to run the following query for each object in A (query below). The filtervar in the query below is not working. Any idea?

query {
f1 (func:eq(dgraph.type, A)) @normalize @cascade {
    filtervar as uid
    AB {
        BD {
           myDforward: name
           DE {
               ~DE {
                     myDbackward: name
                     ~CD {
                         ~AC @filter(uid(filtervar)) {
                               myA: name
                         }
                     }
                }
           }
       }   
    }
  }
}

That is your structure?
I couldn’t understand what you want to do. Can u elaborate?

{
   "set": [
      {
         "uid": "_:RootNode",
         "dgraph.type": "A",
         "AB": [
            {
               "BD": [
                  {
                     "DE": [
                        {
                           "uid": "_:GoReverse0"
                        }
                     ]
                  }
               ]
            }
         ]
      },
      {
         "uid": "_:RootNode",
         "AC": [
            {
               "CD": [
                  {
                     "DE": [
                        {
                           "uid": "_:GoReverse0"
                        }
                     ]
                  }
               ]
            }
         ]
      }
   ]
}
 {
  q(func:eq(dgraph.type, "A")) @recurse  {
    uid
    AB
    BD
    DE 
    ~DE
    ~CD
    ~AC
  }
}