private static Set<RefElement> getPossibleChildren(RefElement refElement) {
    if (!refElement.isValid()) return Collections.emptySet();

    final HashSet<RefElement> newChildren = new HashSet<>();
    for (RefElement refCallee : refElement.getOutReferences()) {
      if (((RefElementImpl)refCallee).isSuspicious()) {
        newChildren.add(refCallee);
      }
    }

    if (refElement instanceof RefMethod refMethod) {
      RefClass aClass = refMethod.getOwnerClass();
      if (!refMethod.isStatic() && !refMethod.isConstructor() && (aClass != null && !aClass.isAnonymous())) {
        for (RefOverridable refDerived : refMethod.getDerivedReferences()) {
          if (refDerived instanceof RefMethodImpl && ((RefMethodImpl)refDerived).isSuspicious() ||
              refDerived instanceof RefFunctionalExpressionImpl && ((RefFunctionalExpressionImpl)refDerived).isSuspicious()) {
            newChildren.add(refDerived);
          }
        }
      }
    } else if (refElement instanceof RefClass refClass) {
      for (RefClass subClass : refClass.getSubClasses()) {
        if ((subClass.isInterface() || subClass.isAbstract()) && ((RefClassImpl)subClass).isSuspicious()) {
          newChildren.add(subClass);
        }
      }

      if (refClass.getDefaultConstructor() instanceof RefImplicitConstructor) {
        Set<RefElement> fromConstructor = getPossibleChildren(refClass.getDefaultConstructor());
        newChildren.addAll(fromConstructor);
      }
    }

    return newChildren;
  }
private static Set<RefElement> getPossibleChildren(RefElement refElement)