private void addToCache(FilteringNode node, boolean duplicate) {
    Object delegate = node.getDelegate();
    Object[] delegates = myBaseStructure.getChildElements(delegate);
    if (delegates.length == 0 || duplicate) {
      myLeaves.add(node);
    } else {
      ArrayList<FilteringNode> nodes = new ArrayList<>(delegates.length);
      for (Object d : delegates) {
        boolean isDuplicate = myDescriptors2Nodes.containsKey(d);
        if (!isDuplicate) {
          FilteringNode n = new FilteringNode(node, d);
          myDescriptors2Nodes.put(d, n);
          nodes.add(n);
        }
      }
      myNodesCache.put(node, nodes);
      for (FilteringNode n : nodes) {
        addToCache(n, false);
      }
      if (nodes.isEmpty()) {
        myLeaves.add(node);
      }
    }
  }
private void addToCache(FilteringNode node, boolean duplicate)