D8, how to make node template aware of entity reference parent
well, this seems to be working. 

function THEME_preprocess_node(&amp;$variables) {
$nid  = $variables['node']-&gt;id();

if ($variables['elements']['#view_mode'] === 'VIEW_MODE') {
// Get the node ID.
    $variables['nid'] = $nid;
    $parent   = $variables['elements']['#node']-&gt;_referringItem-&gt;getEntity();
    $items = $parent-&gt;get('FIELD_NAME')-&gt;getValue();

    foreach ($items as $key =&gt; $item) {
        if ($item['target_id'] == $nid) {
            $variables['tree_position'] = $key;
        }
    }
  }
}


Not sure this is the best way. So any suggestions still welcome.