diff --git a/Common/OctreeInternals.cpp b/Common/OctreeInternals.cpp
index d1d83e01e8138401dc48315b7e02e048dd87638b..b2b4fc8a3be59a8f4d186df4e03bd6a807d20c60 100644
--- a/Common/OctreeInternals.cpp
+++ b/Common/OctreeInternals.cpp
@@ -403,6 +403,18 @@ void *searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_g
 #endif
 
   flag1 = 0;
+  ELink ptr1 = ptrBucket->lhead;
+  while (ptr1 != NULL){
+    flag = xyzInElementBB(_pt, ptr1->region, BBElement);
+    if (flag == 1)
+      flag = xyzInElement(ptr1->region, _pt);
+    if (flag == 1) {
+      _elements->push_back(ptr1->region);
+      flag1 = 1;
+    }
+    ptr1 = ptr1->next;
+  }
+
   for (iter = (ptrBucket->listBB).begin(); 
        iter != (ptrBucket->listBB).end(); iter++){
     flag = xyzInElementBB(_pt, *iter, BBElement);
diff --git a/Geo/MElementOctree.cpp b/Geo/MElementOctree.cpp
index 3bdbf8b7e3405b8d73fca34fa00c9ba0f4fc2d93..eb8e63bf6f478f3a1d2d4885b8b04713e8c2610e 100644
--- a/Geo/MElementOctree.cpp
+++ b/Geo/MElementOctree.cpp
@@ -115,7 +115,16 @@ MElement *MElementOctree::find(double x, double y, double z, int dim)
 {
   double P[3] = {x, y, z};
   MElement *e = (MElement*)Octree_Search(P, _octree);
-
+  if (dim == -1 || !e || e->getDim() == dim)
+    return e;
+  std::list<void*> l;
+  Octree_SearchAll(P, _octree, &l);
+  for (std::list<void*>::iterator it = l.begin(); it != l.end(); it++) {
+    MElement *el = (MElement*) *it;
+    if (el->getDim() == dim)
+      return el;
+  }
+  // JF : can you check if this is still needed, now that we changed Octree_SearchAll
   if (!e || (dim != -1 && e->getDim() != dim)){
     double initialTol = MElement::getTolerance();
     double tol = initialTol;
@@ -129,7 +138,6 @@ MElement *MElementOctree::find(double x, double y, double z, int dim)
 	  e = entities[i]->getMeshElement(j);
 	  if (dim == -1 ||  e->getDim() == dim){
 	    if (MElementInEle(e, P)){
-	      //	      printf("coucou FOUND\n");
 	      MElement::setTolerance(initialTol);
 	      return e;
 	    }	    
@@ -140,16 +148,5 @@ MElement *MElementOctree::find(double x, double y, double z, int dim)
     MElement::setTolerance(initialTol);
     Msg::Warning("Point %g %g %g not found",x,y,z);
   }
-  
-
-  if (dim == -1 || !e || e->getDim() == dim)
-    return e;
-  std::list<void*> l;
-  Octree_SearchAll(P, _octree, &l);
-  for (std::list<void*>::iterator it = l.begin(); it != l.end(); it++) {
-    MElement *el = (MElement*) *it;
-    if (el->getDim() == dim)
-      return el;
-  }
   return NULL;
 }