Try to use caching to prevent building the menu tree multiple times.
Use isset instead of array_key_exists.
Merge branch 'feature/fix-menu-node-issue' into 7.x-1.x

* feature/fix-menu-node-issue:
  Use isset instead of array_key_exists.
  Try to use caching to prevent building the menu tree multiple times.