private static Map<String,VirtualFile> findSiblings(@Nullable VirtualFile directory,Project project,Set<VirtualFile> seen){
  if (directory == null) {
    return Collections.emptyMap();
  }
 else {
    if (seen.contains(directory)) {
      return findSiblings(null,project,seen);
    }
    seen.add(directory);
    VirtualFile settings=directory.findChild(SdkConstants.FN_SETTINGS_GRADLE);
    if (settings == null) {
      return findSiblings(directory.getParent(),project,seen);
    }
 else {
      return GradleModuleImporter.getSubProjects(settings,project);
    }
  }
}

private static Map < String , VirtualFile > findSiblings ( @ Nullable VirtualFile directory , Project project , Set < VirtualFile > seen ) { if ( directory == null ) { return Collections . emptyMap ( ) ; } else { if ( seen . contains ( directory ) ) { return findSiblings ( null , project , seen ) ; } seen . add ( directory ) ; VirtualFile settings = directory . findChild ( SdkConstants . FN_SETTINGS_GRADLE ) ; if ( settings == null ) { return findSiblings ( directory . getParent ( ) , project , seen ) ; } else { return GradleModuleImporter . getSubProjects ( settings , project ) ; } } }
recursively go up the file system tree to find parent project with settings . gradle and then obtain collection of siblings from that file .
